Numerous cleanup and changes. Fix for sound output.

CPU usage is increased however or at the very least, sound
playback isn't very good...
This commit is contained in:
gameblabla 2020-10-13 11:40:31 +02:00
parent 3193f1bcc9
commit 91442a39c5
No known key found for this signature in database
GPG Key ID: B24EFBB23B5F76CB
29 changed files with 355 additions and 473 deletions

View File

@ -1214,7 +1214,7 @@ INLINE void bit_xy(int bit, uint8_t value)
/***************************************************************
* RES bit,r8
***************************************************************/
INLINE uint8_t res(int bit, uint8_t value)
INLINE uint8_t res_z80(int bit, uint8_t value)
{
return value & ~(1<<bit);
}
@ -1624,77 +1624,77 @@ OP(cb,7d) { bit(7, L); } /* BIT 7,L */
OP(cb,7e) { bit_hl(7, rm(HL)); } /* BIT 7,(HL) */
OP(cb,7f) { bit(7, A); } /* BIT 7,A */
OP(cb,80) { B = res(0, B); } /* RES 0,B */
OP(cb,81) { C = res(0, C); } /* RES 0,C */
OP(cb,82) { D = res(0, D); } /* RES 0,D */
OP(cb,83) { E = res(0, E); } /* RES 0,E */
OP(cb,84) { H = res(0, H); } /* RES 0,H */
OP(cb,85) { L = res(0, L); } /* RES 0,L */
OP(cb,86) { wm(HL, res(0, rm(HL))); } /* RES 0,(HL) */
OP(cb,87) { A = res(0, A); } /* RES 0,A */
OP(cb,80) { B = res_z80(0, B); } /* RES 0,B */
OP(cb,81) { C = res_z80(0, C); } /* RES 0,C */
OP(cb,82) { D = res_z80(0, D); } /* RES 0,D */
OP(cb,83) { E = res_z80(0, E); } /* RES 0,E */
OP(cb,84) { H = res_z80(0, H); } /* RES 0,H */
OP(cb,85) { L = res_z80(0, L); } /* RES 0,L */
OP(cb,86) { wm(HL, res_z80(0, rm(HL))); } /* RES 0,(HL) */
OP(cb,87) { A = res_z80(0, A); } /* RES 0,A */
OP(cb,88) { B = res(1, B); } /* RES 1,B */
OP(cb,89) { C = res(1, C); } /* RES 1,C */
OP(cb,8a) { D = res(1, D); } /* RES 1,D */
OP(cb,8b) { E = res(1, E); } /* RES 1,E */
OP(cb,8c) { H = res(1, H); } /* RES 1,H */
OP(cb,8d) { L = res(1, L); } /* RES 1,L */
OP(cb,8e) { wm(HL, res(1, rm(HL))); } /* RES 1,(HL) */
OP(cb,8f) { A = res(1, A); } /* RES 1,A */
OP(cb,88) { B = res_z80(1, B); } /* RES 1,B */
OP(cb,89) { C = res_z80(1, C); } /* RES 1,C */
OP(cb,8a) { D = res_z80(1, D); } /* RES 1,D */
OP(cb,8b) { E = res_z80(1, E); } /* RES 1,E */
OP(cb,8c) { H = res_z80(1, H); } /* RES 1,H */
OP(cb,8d) { L = res_z80(1, L); } /* RES 1,L */
OP(cb,8e) { wm(HL, res_z80(1, rm(HL))); } /* RES 1,(HL) */
OP(cb,8f) { A = res_z80(1, A); } /* RES 1,A */
OP(cb,90) { B = res(2, B); } /* RES 2,B */
OP(cb,91) { C = res(2, C); } /* RES 2,C */
OP(cb,92) { D = res(2, D); } /* RES 2,D */
OP(cb,93) { E = res(2, E); } /* RES 2,E */
OP(cb,94) { H = res(2, H); } /* RES 2,H */
OP(cb,95) { L = res(2, L); } /* RES 2,L */
OP(cb,96) { wm(HL, res(2, rm(HL))); } /* RES 2,(HL) */
OP(cb,97) { A = res(2, A); } /* RES 2,A */
OP(cb,90) { B = res_z80(2, B); } /* RES 2,B */
OP(cb,91) { C = res_z80(2, C); } /* RES 2,C */
OP(cb,92) { D = res_z80(2, D); } /* RES 2,D */
OP(cb,93) { E = res_z80(2, E); } /* RES 2,E */
OP(cb,94) { H = res_z80(2, H); } /* RES 2,H */
OP(cb,95) { L = res_z80(2, L); } /* RES 2,L */
OP(cb,96) { wm(HL, res_z80(2, rm(HL))); } /* RES 2,(HL) */
OP(cb,97) { A = res_z80(2, A); } /* RES 2,A */
OP(cb,98) { B = res(3, B); } /* RES 3,B */
OP(cb,99) { C = res(3, C); } /* RES 3,C */
OP(cb,9a) { D = res(3, D); } /* RES 3,D */
OP(cb,9b) { E = res(3, E); } /* RES 3,E */
OP(cb,9c) { H = res(3, H); } /* RES 3,H */
OP(cb,9d) { L = res(3, L); } /* RES 3,L */
OP(cb,9e) { wm(HL, res(3, rm(HL))); } /* RES 3,(HL) */
OP(cb,9f) { A = res(3, A); } /* RES 3,A */
OP(cb,98) { B = res_z80(3, B); } /* RES 3,B */
OP(cb,99) { C = res_z80(3, C); } /* RES 3,C */
OP(cb,9a) { D = res_z80(3, D); } /* RES 3,D */
OP(cb,9b) { E = res_z80(3, E); } /* RES 3,E */
OP(cb,9c) { H = res_z80(3, H); } /* RES 3,H */
OP(cb,9d) { L = res_z80(3, L); } /* RES 3,L */
OP(cb,9e) { wm(HL, res_z80(3, rm(HL))); } /* RES 3,(HL) */
OP(cb,9f) { A = res_z80(3, A); } /* RES 3,A */
OP(cb,a0) { B = res(4, B); } /* RES 4,B */
OP(cb,a1) { C = res(4, C); } /* RES 4,C */
OP(cb,a2) { D = res(4, D); } /* RES 4,D */
OP(cb,a3) { E = res(4, E); } /* RES 4,E */
OP(cb,a4) { H = res(4, H); } /* RES 4,H */
OP(cb,a5) { L = res(4, L); } /* RES 4,L */
OP(cb,a6) { wm(HL, res(4, rm(HL))); } /* RES 4,(HL) */
OP(cb,a7) { A = res(4, A); } /* RES 4,A */
OP(cb,a0) { B = res_z80(4, B); } /* RES 4,B */
OP(cb,a1) { C = res_z80(4, C); } /* RES 4,C */
OP(cb,a2) { D = res_z80(4, D); } /* RES 4,D */
OP(cb,a3) { E = res_z80(4, E); } /* RES 4,E */
OP(cb,a4) { H = res_z80(4, H); } /* RES 4,H */
OP(cb,a5) { L = res_z80(4, L); } /* RES 4,L */
OP(cb,a6) { wm(HL, res_z80(4, rm(HL))); } /* RES 4,(HL) */
OP(cb,a7) { A = res_z80(4, A); } /* RES 4,A */
OP(cb,a8) { B = res(5, B); } /* RES 5,B */
OP(cb,a9) { C = res(5, C); } /* RES 5,C */
OP(cb,aa) { D = res(5, D); } /* RES 5,D */
OP(cb,ab) { E = res(5, E); } /* RES 5,E */
OP(cb,ac) { H = res(5, H); } /* RES 5,H */
OP(cb,ad) { L = res(5, L); } /* RES 5,L */
OP(cb,ae) { wm(HL, res(5, rm(HL))); } /* RES 5,(HL) */
OP(cb,af) { A = res(5, A); } /* RES 5,A */
OP(cb,a8) { B = res_z80(5, B); } /* RES 5,B */
OP(cb,a9) { C = res_z80(5, C); } /* RES 5,C */
OP(cb,aa) { D = res_z80(5, D); } /* RES 5,D */
OP(cb,ab) { E = res_z80(5, E); } /* RES 5,E */
OP(cb,ac) { H = res_z80(5, H); } /* RES 5,H */
OP(cb,ad) { L = res_z80(5, L); } /* RES 5,L */
OP(cb,ae) { wm(HL, res_z80(5, rm(HL))); } /* RES 5,(HL) */
OP(cb,af) { A = res_z80(5, A); } /* RES 5,A */
OP(cb,b0) { B = res(6, B); } /* RES 6,B */
OP(cb,b1) { C = res(6, C); } /* RES 6,C */
OP(cb,b2) { D = res(6, D); } /* RES 6,D */
OP(cb,b3) { E = res(6, E); } /* RES 6,E */
OP(cb,b4) { H = res(6, H); } /* RES 6,H */
OP(cb,b5) { L = res(6, L); } /* RES 6,L */
OP(cb,b6) { wm(HL, res(6, rm(HL))); } /* RES 6,(HL) */
OP(cb,b7) { A = res(6, A); } /* RES 6,A */
OP(cb,b0) { B = res_z80(6, B); } /* RES 6,B */
OP(cb,b1) { C = res_z80(6, C); } /* RES 6,C */
OP(cb,b2) { D = res_z80(6, D); } /* RES 6,D */
OP(cb,b3) { E = res_z80(6, E); } /* RES 6,E */
OP(cb,b4) { H = res_z80(6, H); } /* RES 6,H */
OP(cb,b5) { L = res_z80(6, L); } /* RES 6,L */
OP(cb,b6) { wm(HL, res_z80(6, rm(HL))); } /* RES 6,(HL) */
OP(cb,b7) { A = res_z80(6, A); } /* RES 6,A */
OP(cb,b8) { B = res(7, B); } /* RES 7,B */
OP(cb,b9) { C = res(7, C); } /* RES 7,C */
OP(cb,ba) { D = res(7, D); } /* RES 7,D */
OP(cb,bb) { E = res(7, E); } /* RES 7,E */
OP(cb,bc) { H = res(7, H); } /* RES 7,H */
OP(cb,bd) { L = res(7, L); } /* RES 7,L */
OP(cb,be) { wm(HL, res(7, rm(HL))); } /* RES 7,(HL) */
OP(cb,bf) { A = res(7, A); } /* RES 7,A */
OP(cb,b8) { B = res_z80(7, B); } /* RES 7,B */
OP(cb,b9) { C = res_z80(7, C); } /* RES 7,C */
OP(cb,ba) { D = res_z80(7, D); } /* RES 7,D */
OP(cb,bb) { E = res_z80(7, E); } /* RES 7,E */
OP(cb,bc) { H = res_z80(7, H); } /* RES 7,H */
OP(cb,bd) { L = res_z80(7, L); } /* RES 7,L */
OP(cb,be) { wm(HL, res_z80(7, rm(HL))); } /* RES 7,(HL) */
OP(cb,bf) { A = res_z80(7, A); } /* RES 7,A */
OP(cb,c0) { B = set(0, B); } /* SET 0,B */
OP(cb,c1) { C = set(0, C); } /* SET 0,C */
@ -1917,77 +1917,77 @@ OP(xycb,7d) { xycb_7e(); } /* BIT 7,(XY+o) */
OP(xycb,7e) { bit_xy(7, rm(Z80.ea)); } /* BIT 7,(XY+o) */
OP(xycb,7f) { xycb_7e(); } /* BIT 7,(XY+o) */
OP(xycb,80) { B = res(0, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 0,B=(XY+o) */
OP(xycb,81) { C = res(0, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 0,C=(XY+o) */
OP(xycb,82) { D = res(0, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 0,D=(XY+o) */
OP(xycb,83) { E = res(0, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 0,E=(XY+o) */
OP(xycb,84) { H = res(0, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 0,H=(XY+o) */
OP(xycb,85) { L = res(0, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 0,L=(XY+o) */
OP(xycb,86) { wm(Z80.ea, res(0, rm(Z80.ea))); } /* RES 0,(XY+o) */
OP(xycb,87) { A = res(0, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 0,A=(XY+o) */
OP(xycb,80) { B = res_z80(0, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 0,B=(XY+o) */
OP(xycb,81) { C = res_z80(0, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 0,C=(XY+o) */
OP(xycb,82) { D = res_z80(0, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 0,D=(XY+o) */
OP(xycb,83) { E = res_z80(0, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 0,E=(XY+o) */
OP(xycb,84) { H = res_z80(0, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 0,H=(XY+o) */
OP(xycb,85) { L = res_z80(0, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 0,L=(XY+o) */
OP(xycb,86) { wm(Z80.ea, res_z80(0, rm(Z80.ea))); } /* RES 0,(XY+o) */
OP(xycb,87) { A = res_z80(0, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 0,A=(XY+o) */
OP(xycb,88) { B = res(1, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 1,B=(XY+o) */
OP(xycb,89) { C = res(1, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 1,C=(XY+o) */
OP(xycb,8a) { D = res(1, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 1,D=(XY+o) */
OP(xycb,8b) { E = res(1, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 1,E=(XY+o) */
OP(xycb,8c) { H = res(1, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 1,H=(XY+o) */
OP(xycb,8d) { L = res(1, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 1,L=(XY+o) */
OP(xycb,8e) { wm(Z80.ea, res(1, rm(Z80.ea))); } /* RES 1,(XY+o) */
OP(xycb,8f) { A = res(1, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 1,A=(XY+o) */
OP(xycb,88) { B = res_z80(1, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 1,B=(XY+o) */
OP(xycb,89) { C = res_z80(1, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 1,C=(XY+o) */
OP(xycb,8a) { D = res_z80(1, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 1,D=(XY+o) */
OP(xycb,8b) { E = res_z80(1, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 1,E=(XY+o) */
OP(xycb,8c) { H = res_z80(1, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 1,H=(XY+o) */
OP(xycb,8d) { L = res_z80(1, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 1,L=(XY+o) */
OP(xycb,8e) { wm(Z80.ea, res_z80(1, rm(Z80.ea))); } /* RES 1,(XY+o) */
OP(xycb,8f) { A = res_z80(1, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 1,A=(XY+o) */
OP(xycb,90) { B = res(2, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 2,B=(XY+o) */
OP(xycb,91) { C = res(2, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 2,C=(XY+o) */
OP(xycb,92) { D = res(2, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 2,D=(XY+o) */
OP(xycb,93) { E = res(2, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 2,E=(XY+o) */
OP(xycb,94) { H = res(2, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 2,H=(XY+o) */
OP(xycb,95) { L = res(2, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 2,L=(XY+o) */
OP(xycb,96) { wm(Z80.ea, res(2, rm(Z80.ea))); } /* RES 2,(XY+o) */
OP(xycb,97) { A = res(2, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 2,A=(XY+o) */
OP(xycb,90) { B = res_z80(2, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 2,B=(XY+o) */
OP(xycb,91) { C = res_z80(2, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 2,C=(XY+o) */
OP(xycb,92) { D = res_z80(2, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 2,D=(XY+o) */
OP(xycb,93) { E = res_z80(2, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 2,E=(XY+o) */
OP(xycb,94) { H = res_z80(2, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 2,H=(XY+o) */
OP(xycb,95) { L = res_z80(2, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 2,L=(XY+o) */
OP(xycb,96) { wm(Z80.ea, res_z80(2, rm(Z80.ea))); } /* RES 2,(XY+o) */
OP(xycb,97) { A = res_z80(2, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 2,A=(XY+o) */
OP(xycb,98) { B = res(3, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 3,B=(XY+o) */
OP(xycb,99) { C = res(3, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 3,C=(XY+o) */
OP(xycb,9a) { D = res(3, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 3,D=(XY+o) */
OP(xycb,9b) { E = res(3, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 3,E=(XY+o) */
OP(xycb,9c) { H = res(3, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 3,H=(XY+o) */
OP(xycb,9d) { L = res(3, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 3,L=(XY+o) */
OP(xycb,9e) { wm(Z80.ea, res(3, rm(Z80.ea))); } /* RES 3,(XY+o) */
OP(xycb,9f) { A = res(3, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 3,A=(XY+o) */
OP(xycb,98) { B = res_z80(3, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 3,B=(XY+o) */
OP(xycb,99) { C = res_z80(3, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 3,C=(XY+o) */
OP(xycb,9a) { D = res_z80(3, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 3,D=(XY+o) */
OP(xycb,9b) { E = res_z80(3, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 3,E=(XY+o) */
OP(xycb,9c) { H = res_z80(3, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 3,H=(XY+o) */
OP(xycb,9d) { L = res_z80(3, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 3,L=(XY+o) */
OP(xycb,9e) { wm(Z80.ea, res_z80(3, rm(Z80.ea))); } /* RES 3,(XY+o) */
OP(xycb,9f) { A = res_z80(3, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 3,A=(XY+o) */
OP(xycb,a0) { B = res(4, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 4,B=(XY+o) */
OP(xycb,a1) { C = res(4, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 4,C=(XY+o) */
OP(xycb,a2) { D = res(4, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 4,D=(XY+o) */
OP(xycb,a3) { E = res(4, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 4,E=(XY+o) */
OP(xycb,a4) { H = res(4, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 4,H=(XY+o) */
OP(xycb,a5) { L = res(4, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 4,L=(XY+o) */
OP(xycb,a6) { wm(Z80.ea, res(4, rm(Z80.ea))); } /* RES 4,(XY+o) */
OP(xycb,a7) { A = res(4, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 4,A=(XY+o) */
OP(xycb,a0) { B = res_z80(4, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 4,B=(XY+o) */
OP(xycb,a1) { C = res_z80(4, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 4,C=(XY+o) */
OP(xycb,a2) { D = res_z80(4, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 4,D=(XY+o) */
OP(xycb,a3) { E = res_z80(4, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 4,E=(XY+o) */
OP(xycb,a4) { H = res_z80(4, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 4,H=(XY+o) */
OP(xycb,a5) { L = res_z80(4, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 4,L=(XY+o) */
OP(xycb,a6) { wm(Z80.ea, res_z80(4, rm(Z80.ea))); } /* RES 4,(XY+o) */
OP(xycb,a7) { A = res_z80(4, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 4,A=(XY+o) */
OP(xycb,a8) { B = res(5, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 5,B=(XY+o) */
OP(xycb,a9) { C = res(5, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 5,C=(XY+o) */
OP(xycb,aa) { D = res(5, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 5,D=(XY+o) */
OP(xycb,ab) { E = res(5, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 5,E=(XY+o) */
OP(xycb,ac) { H = res(5, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 5,H=(XY+o) */
OP(xycb,ad) { L = res(5, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 5,L=(XY+o) */
OP(xycb,ae) { wm(Z80.ea, res(5, rm(Z80.ea))); } /* RES 5,(XY+o) */
OP(xycb,af) { A = res(5, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 5,A=(XY+o) */
OP(xycb,a8) { B = res_z80(5, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 5,B=(XY+o) */
OP(xycb,a9) { C = res_z80(5, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 5,C=(XY+o) */
OP(xycb,aa) { D = res_z80(5, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 5,D=(XY+o) */
OP(xycb,ab) { E = res_z80(5, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 5,E=(XY+o) */
OP(xycb,ac) { H = res_z80(5, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 5,H=(XY+o) */
OP(xycb,ad) { L = res_z80(5, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 5,L=(XY+o) */
OP(xycb,ae) { wm(Z80.ea, res_z80(5, rm(Z80.ea))); } /* RES 5,(XY+o) */
OP(xycb,af) { A = res_z80(5, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 5,A=(XY+o) */
OP(xycb,b0) { B = res(6, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 6,B=(XY+o) */
OP(xycb,b1) { C = res(6, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 6,C=(XY+o) */
OP(xycb,b2) { D = res(6, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 6,D=(XY+o) */
OP(xycb,b3) { E = res(6, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 6,E=(XY+o) */
OP(xycb,b4) { H = res(6, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 6,H=(XY+o) */
OP(xycb,b5) { L = res(6, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 6,L=(XY+o) */
OP(xycb,b6) { wm(Z80.ea, res(6, rm(Z80.ea))); } /* RES 6,(XY+o) */
OP(xycb,b7) { A = res(6, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 6,A=(XY+o) */
OP(xycb,b0) { B = res_z80(6, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 6,B=(XY+o) */
OP(xycb,b1) { C = res_z80(6, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 6,C=(XY+o) */
OP(xycb,b2) { D = res_z80(6, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 6,D=(XY+o) */
OP(xycb,b3) { E = res_z80(6, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 6,E=(XY+o) */
OP(xycb,b4) { H = res_z80(6, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 6,H=(XY+o) */
OP(xycb,b5) { L = res_z80(6, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 6,L=(XY+o) */
OP(xycb,b6) { wm(Z80.ea, res_z80(6, rm(Z80.ea))); } /* RES 6,(XY+o) */
OP(xycb,b7) { A = res_z80(6, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 6,A=(XY+o) */
OP(xycb,b8) { B = res(7, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 7,B=(XY+o) */
OP(xycb,b9) { C = res(7, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 7,C=(XY+o) */
OP(xycb,ba) { D = res(7, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 7,D=(XY+o) */
OP(xycb,bb) { E = res(7, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 7,E=(XY+o) */
OP(xycb,bc) { H = res(7, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 7,H=(XY+o) */
OP(xycb,bd) { L = res(7, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 7,L=(XY+o) */
OP(xycb,be) { wm(Z80.ea, res(7, rm(Z80.ea))); } /* RES 7,(XY+o) */
OP(xycb,bf) { A = res(7, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 7,A=(XY+o) */
OP(xycb,b8) { B = res_z80(7, rm(Z80.ea)); wm(Z80.ea, B); } /* RES 7,B=(XY+o) */
OP(xycb,b9) { C = res_z80(7, rm(Z80.ea)); wm(Z80.ea, C); } /* RES 7,C=(XY+o) */
OP(xycb,ba) { D = res_z80(7, rm(Z80.ea)); wm(Z80.ea, D); } /* RES 7,D=(XY+o) */
OP(xycb,bb) { E = res_z80(7, rm(Z80.ea)); wm(Z80.ea, E); } /* RES 7,E=(XY+o) */
OP(xycb,bc) { H = res_z80(7, rm(Z80.ea)); wm(Z80.ea, H); } /* RES 7,H=(XY+o) */
OP(xycb,bd) { L = res_z80(7, rm(Z80.ea)); wm(Z80.ea, L); } /* RES 7,L=(XY+o) */
OP(xycb,be) { wm(Z80.ea, res_z80(7, rm(Z80.ea))); } /* RES 7,(XY+o) */
OP(xycb,bf) { A = res_z80(7, rm(Z80.ea)); wm(Z80.ea, A); } /* RES 7,A=(XY+o) */
OP(xycb,c0) { B = set(0, rm(Z80.ea)); wm(Z80.ea, B); } /* SET 0,B=(XY+o) */
OP(xycb,c1) { C = set(0, rm(Z80.ea)); wm(Z80.ea, C); } /* SET 0,C=(XY+o) */

View File

@ -70,7 +70,7 @@ void z80_init(int32_t (*irqcallback)(int32_t));
void z80_reset (void);
void z80_exit (void);
int32_t z80_execute(int32_t cycles);
void z80_set_irq_line(int32_t irqline, int32_t state);
void z80_set_irq_line(int32_t inputnum, int32_t state);
void z80_reset_cycle_count(void);
int32_t z80_get_elapsed_cycles(void);

View File

@ -119,7 +119,7 @@ static void video_update()
}
else
{
uint32_t hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
dst.x = hide_left ? 16 : 0;
dst.y = 0;
dst.w = (hide_left ? 248 : 256)*2;
@ -1032,7 +1032,7 @@ int main (int argc, char *argv[])
SDL_WM_SetCaption("SMS Plus GX Super", "SMS Plus GX Super");
sdl_screen = SDL_SetVideoMode(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, SDL_HWSURFACE);
sdl_screen = SDL_SetVideoMode(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, SDL_HWSURFACE | SDL_TRIPLEBUF);
sms_bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEO_WIDTH_SMS, 267, 16, 0, 0, 0, 0);
backbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, 0, 0, 0, 0);
miniscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, 0, 0, 0, 0);
@ -1041,8 +1041,6 @@ int main (int argc, char *argv[])
sdl_joy[0] = SDL_JoystickOpen(0);
SDL_JoystickEventState(SDL_ENABLE);
Sound_Init();
#ifdef SCALE2X_UPSCALER
scale2x_buf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEO_WIDTH_SMS*2, 480, 16, 0, 0, 0, 0);
#endif
@ -1053,7 +1051,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -1070,18 +1067,20 @@ int main (int argc, char *argv[])
// Initialize all systems and power on
system_poweron();
Sound_Init();
// Loop until the user closes the window
while (!quit)
{
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();

View File

@ -728,7 +728,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -744,11 +743,11 @@ int main (int argc, char *argv[])
bios_init();
Sound_Init();
// Initialize all systems and power on
system_poweron();
Sound_Init();
// Loop until the user closes the window
while (!quit)
{
@ -758,8 +757,8 @@ int main (int argc, char *argv[])
// Refresh video data
video_update();
// Output audio
Sound_Update();
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
if (selectpressed == 1)
{

View File

@ -957,7 +957,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -980,12 +979,12 @@ int main (int argc, char *argv[])
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();

View File

@ -688,8 +688,6 @@ int main (int argc, char *argv[])
vinfo.yoffset = 0;
ioctl(fbfd, FBIOPAN_DISPLAY, &vinfo);
Sound_Init();
#ifdef SCALE2X_UPSCALER
scale2x_buf = malloc(((VIDEO_WIDTH_SMS*2)*480)*sizeof(uint16_t));
#endif
@ -700,7 +698,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap;
bitmap.pitch = 512;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -717,6 +714,8 @@ int main (int argc, char *argv[])
// Initialize all systems and power on
system_poweron();
Sound_Init();
Clear_buffers();
// Loop until the user closes the window
@ -725,6 +724,9 @@ int main (int argc, char *argv[])
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
@ -736,9 +738,6 @@ int main (int argc, char *argv[])
}
Controls();
// Output audio
Sound_Update();
}
config_save();

View File

@ -637,7 +637,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -660,12 +659,12 @@ int main (int argc, char *argv[])
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();

View File

@ -1111,7 +1111,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -1197,9 +1196,6 @@ int main (int argc, char *argv[])
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
update_window_size(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 1);

View File

@ -108,8 +108,6 @@ static void video_update()
case 2: // Fullscreen (cropped)
if (sms.console == CONSOLE_GG)
{
dst.x = 0;
dst.y = 0;
dst.w = sdl_screen->w;
dst.h = sdl_screen->h;
dstT.x = 48;
@ -119,8 +117,6 @@ static void video_update()
}
else
{
dst.x = 0;
dst.y = 0;
dst.w = sdl_screen->w;
dst.h = sdl_screen->h;
dstT.x = (vdp.reg[0] & 0x20) ? 8 : 0;
@ -807,7 +803,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -823,11 +818,11 @@ int main (int argc, char *argv[])
bios_init();
Sound_Init();
// Initialize all systems and power on
system_poweron();
Sound_Init();
// Loop until the user closes the window
while (!quit)
{
@ -837,8 +832,8 @@ int main (int argc, char *argv[])
// Refresh video data
video_update();
// Output audio
Sound_Update();
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
if (sms.console == CONSOLE_COLECO)
{

View File

@ -974,7 +974,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -997,12 +996,12 @@ int main (int argc, char *argv[])
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();

View File

@ -12,11 +12,11 @@
#include "smsplus.h"
#include "font_drawing.h"
/* TODO : We really need to do something about the tearing.
* This is not the only port affected btw but still. */
#ifdef NOYUV
SDL_Color palette_8bpp[256];
uint8_t drm_palette[3][256];
#else
static uint8_t drm_palette[3][256];
#endif
static gamedata_t gdata;
@ -27,9 +27,8 @@ SDL_Surface *sms_bitmap;
static char home_path[256];
static uint8_t selectpressed = 0;
static uint8_t save_slot = 0;
static uint8_t quit = 0;
static uint_fast8_t save_slot = 0;
static uint_fast8_t quit = 0;
#ifndef NOYUV
#define UINT16_16(val) ((uint32_t)(val * (float)(1<<16)))
@ -40,22 +39,18 @@ static const uint32_t YUV_MAT[3][3] = {
};
#endif
uint_fast8_t forcerefresh = 0;
uint_fast16_t remember_res_height = 240, width_remember = 256;
uint_fast16_t pixels_shifting_remove;
static uint_fast8_t forcerefresh = 0;
static uint32_t update_window_size(uint32_t w, uint32_t h);
static uint8_t* dst_yuv[3];
/* This is solely relying on the IPU chip implemented in the kernel
* for centering, scaling (with bilinear filtering) etc...
*/
static void video_update(void)
{
uint16_t height;
uint16_t width;
uint16_t i;
uint_fast8_t j, a, plane;
uint8_t* dst_yuv[3];
uint_fast16_t height, width, i, pixels_shifting_remove;
uint_fast8_t a, plane;
if (sms.console == CONSOLE_GG)
{
@ -65,7 +60,7 @@ static void video_update(void)
pixels_shifting_remove = (256 * 24) + 48;
height = 144;
width = 160;
if (remember_res_height != 144 || forcerefresh == 1)
if (sdl_screen->h != 144 || forcerefresh == 1)
{
update_window_size(160, 144);
forcerefresh = 0;
@ -76,7 +71,7 @@ static void video_update(void)
pixels_shifting_remove = (vdp.reg[0] & 0x20) ? 8 : 0;
height = vdp.height;
width = 256 - pixels_shifting_remove;
if (width != width_remember || remember_res_height != vdp.height || forcerefresh == 1)
if (width != sdl_screen->w || sdl_screen->h != vdp.height || forcerefresh == 1)
{
update_window_size(width, vdp.height);
forcerefresh = 0;
@ -85,24 +80,26 @@ static void video_update(void)
/* Yes, this mess is really for the 8-bits palette mode.*/
if (bitmap.pal.update == 1){
for(i = 0; i < PALETTE_SIZE; i += 1){
if(bitmap.pal.dirty[i]){
for(a=0;a<8;a++){
for(i = 0; i < PALETTE_SIZE; i += 1)
{
if(bitmap.pal.dirty[i])
{
for(a=0;a<8;a++)
{
#ifdef NOYUV
palette_8bpp[i+(a*32)].r = (bitmap.pal.color[i][0]);
palette_8bpp[i+(a*32)].g = (bitmap.pal.color[i][1]);
palette_8bpp[i+(a*32)].b = (bitmap.pal.color[i][2]);
#else
/* Set DRM palette */
drm_palette[0][i+(a*32)] = ( ( UINT16_16( 0) + YUV_MAT[0][0] * bitmap.pal.color[i][0] + YUV_MAT[0][1] * bitmap.pal.color[i][1] + YUV_MAT[0][2] * bitmap.pal.color[i][2]) >> 16 );
drm_palette[1][i+(a*32)] = ( ( UINT16_16(128) - YUV_MAT[1][0] * bitmap.pal.color[i][0] - YUV_MAT[1][1] * bitmap.pal.color[i][1] + YUV_MAT[1][2] * bitmap.pal.color[i][2]) >> 16 );
drm_palette[2][i+(a*32)] = ( ( UINT16_16(128) + YUV_MAT[2][0] * bitmap.pal.color[i][0] - YUV_MAT[2][1] * bitmap.pal.color[i][1] - YUV_MAT[2][2] * bitmap.pal.color[i][2]) >> 16 );
#endif
}
}
}
/* Set DRM palette */
#ifndef NOYUV
for (i = 0; i < 256; i++){
drm_palette[0][i] = ( ( UINT16_16( 0) + YUV_MAT[0][0] * palette_8bpp[i].r + YUV_MAT[0][1] * palette_8bpp[i].g + YUV_MAT[0][2] * palette_8bpp[i].b) >> 16 );
drm_palette[1][i] = ( ( UINT16_16(128) - YUV_MAT[1][0] * palette_8bpp[i].r - YUV_MAT[1][1] * palette_8bpp[i].g + YUV_MAT[1][2] * palette_8bpp[i].b) >> 16 );
drm_palette[2][i] = ( ( UINT16_16(128) + YUV_MAT[2][0] * palette_8bpp[i].r - YUV_MAT[2][1] * palette_8bpp[i].g - YUV_MAT[2][2] * palette_8bpp[i].b) >> 16 );
}
#else
#ifdef NOYUV
SDL_SetPalette(sms_bitmap, SDL_LOGPAL|SDL_PHYSPAL, palette_8bpp, 0, 256);
SDL_SetPalette(sdl_screen, SDL_LOGPAL|SDL_PHYSPAL, palette_8bpp, 0, 256);
#endif
@ -118,7 +115,6 @@ static void video_update(void)
* However Johnny's code is not used because during my testing it was slower.
* He still helped me understand the YUV code though, so thanks.
* */
uint32_t srcwidth = sms_bitmap->w;
uint8_t *srcbase = sms_bitmap->pixels + pixels_shifting_remove;
dst_yuv[0] = sdl_screen->pixels;
dst_yuv[1] = dst_yuv[0] + height * sdl_screen->pitch;
@ -129,7 +125,7 @@ static void video_update(void)
register uint8_t *pal = drm_palette[plane];
for (y=0; y < height; y++) /* The number of lines to copy */
{
register uint8_t *src = srcbase + (y*srcwidth);
register uint8_t *src = srcbase + (y*sms_bitmap->w);
register uint8_t *end = src + width;
register uint32_t *dst = (uint32_t *)&dst_yuv[plane][width * y];
@ -223,11 +219,41 @@ void system_manage_sram(uint8_t *sram, uint8_t slot_number, uint8_t mode)
}
}
static uint32_t sdl_controls_update_input(SDLKey k, int32_t p)
static uint32_t sdl_controls_update_input_down(SDLKey k)
{
if (k == option.config_buttons[CONFIG_BUTTON_UP])
{
input.pad[0] |= INPUT_UP;
}
else if (k == option.config_buttons[CONFIG_BUTTON_LEFT])
{
input.pad[0] |= INPUT_LEFT;
}
else if (k == option.config_buttons[CONFIG_BUTTON_RIGHT])
{
input.pad[0] |= INPUT_RIGHT;
}
else if (k == option.config_buttons[CONFIG_BUTTON_DOWN])
{
input.pad[0] |= INPUT_DOWN;
}
else if (k == option.config_buttons[CONFIG_BUTTON_BUTTON1])
{
input.pad[0] |= INPUT_BUTTON1;
}
else if (k == option.config_buttons[CONFIG_BUTTON_BUTTON2])
{
input.pad[0] |= INPUT_BUTTON2;
}
else if (k == option.config_buttons[CONFIG_BUTTON_START])
{
input.system |= (sms.console == CONSOLE_GG) ? INPUT_START : INPUT_PAUSE;
}
/* We can't use switch... case because we are not using constants */
if (sms.console == CONSOLE_COLECO)
{
input.system = 0;
coleco.keypad[0] = 0xff;
coleco.keypad[1] = 0xff;
@ -244,61 +270,38 @@ static uint32_t sdl_controls_update_input(SDLKey k, int32_t p)
else if (k == option.config_buttons[CONFIG_BUTTON_ASTERISK]) coleco.keypad[0] = 11;
}
return 1;
}
static uint32_t sdl_controls_update_input_release(SDLKey k)
{
if (k == option.config_buttons[CONFIG_BUTTON_UP])
{
if (p)
input.pad[0] |= INPUT_UP;
else
input.pad[0] &= ~INPUT_UP;
input.pad[0] &= ~INPUT_UP;
}
else if (k == option.config_buttons[CONFIG_BUTTON_LEFT])
{
if (p)
input.pad[0] |= INPUT_LEFT;
else
input.pad[0] &= ~INPUT_LEFT;
input.pad[0] &= ~INPUT_LEFT;
}
else if (k == option.config_buttons[CONFIG_BUTTON_RIGHT])
{
if (p)
input.pad[0] |= INPUT_RIGHT;
else
input.pad[0] &= ~INPUT_RIGHT;
input.pad[0] &= ~INPUT_RIGHT;
}
else if (k == option.config_buttons[CONFIG_BUTTON_DOWN])
{
if (p)
input.pad[0] |= INPUT_DOWN;
else
input.pad[0] &= ~INPUT_DOWN;
input.pad[0] &= ~INPUT_DOWN;
}
else if (k == option.config_buttons[CONFIG_BUTTON_BUTTON1])
{
if (p)
input.pad[0] |= INPUT_BUTTON1;
else
input.pad[0] &= ~INPUT_BUTTON1;
input.pad[0] &= ~INPUT_BUTTON1;
}
else if (k == option.config_buttons[CONFIG_BUTTON_BUTTON2])
{
if (p)
input.pad[0] |= INPUT_BUTTON2;
else
input.pad[0] &= ~INPUT_BUTTON2;
input.pad[0] &= ~INPUT_BUTTON2;
}
else if (k == option.config_buttons[CONFIG_BUTTON_START])
{
if (p)
input.system |= (sms.console == CONSOLE_GG) ? INPUT_START : INPUT_PAUSE;
else
input.system &= (sms.console == CONSOLE_GG) ? ~INPUT_START : ~INPUT_PAUSE;
}
else if (k == SDLK_RCTRL || k == SDLK_ESCAPE)
{
if (p)
selectpressed = 1;
else
selectpressed = 0;
input.system &= (sms.console == CONSOLE_GG) ? ~INPUT_START : ~INPUT_PAUSE;
}
if (sms.console == CONSOLE_COLECO) input.system = 0;
@ -399,53 +402,40 @@ static const char* Return_Text_Button(uint32_t button)
/* UP button */
case 273:
return "DPAD UP";
break;
/* DOWN button */
case 274:
return "DPAD DOWN";
break;
/* LEFT button */
case 276:
return "DPAD LEFT";
break;
/* RIGHT button */
case 275:
return "DPAD RIGHT";
break;
/* A button */
case 306:
return "A button";
break;
/* B button */
case 308:
return "B button";
break;
/* X button */
case 304:
return "X button";
break;
/* Y button */
case 32:
return "Y button";
break;
/* L button */
case 9:
return "L Shoulder";
break;
/* R button */
case 8:
return "R Shoulder";
break;
/* Start */
case 13:
return "Start button";
break;
case 27:
return "Select button";
break;
default:
return "...";
break;
}
}
@ -540,7 +530,7 @@ static void Input_Remapping()
default:
SDL_FillRect( backbuffer, NULL, 0 );
print_string("Press button for mapping", TextWhite, TextBlue, 24, 64, backbuffer->pixels);
bitmap_scale(0,0,240,160,sdl_screen->w,sdl_screen->h,240,0,(uint16_t* restrict)backbuffer->pixels,(uint16_t* restrict)sdl_screen->pixels);
SDL_BlitSurface(backbuffer, NULL, sdl_screen, NULL);
SDL_Flip(sdl_screen);
exit_map = 0;
while( !exit_map )
@ -636,26 +626,23 @@ static void Input_Remapping()
if (currentselection == 11) print_string(text, TextRed, 0, 145, 65, backbuffer->pixels);
else print_string(text, TextWhite, 0, 145, 65, backbuffer->pixels);
}
bitmap_scale(0,0,240,160,sdl_screen->w,sdl_screen->h,240,0,(uint16_t* restrict)backbuffer->pixels,(uint16_t* restrict)sdl_screen->pixels);
SDL_BlitSurface(backbuffer, NULL, sdl_screen, NULL);
SDL_Flip(sdl_screen);
}
}
void Menu()
static void Menu()
{
uint_fast8_t i;
char text[50];
int16_t pressed = 0;
int16_t currentselection = 1;
SDL_Rect dstRect;
SDL_Event Event;
sdl_screen = SDL_SetVideoMode(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, SDL_SWSURFACE);
while (((currentselection != 1) && (currentselection != 8)) || (!pressed))
while (((currentselection != 1) && (currentselection != 7)) || (!pressed))
{
pressed = 0;
SDL_FillRect( backbuffer, NULL, 0 );
@ -675,24 +662,19 @@ void Menu()
if (currentselection == 3) print_string(text, TextBlue, 0, 5, 51, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 51, backbuffer->pixels);
snprintf(text, sizeof(text), "Sound volume : %d", option.soundlevel);
if (currentselection == 4) print_string(text, TextBlue, 0, 5, 63, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 63, backbuffer->pixels);
if (currentselection == 5) print_string("Input remapping", TextBlue, 0, 5, 75, backbuffer->pixels);
else print_string("Input remapping", TextWhite, 0, 5, 75, backbuffer->pixels);
if (currentselection == 4) print_string("Input remapping", TextBlue, 0, 5, 63, backbuffer->pixels);
else print_string("Input remapping", TextWhite, 0, 5, 63, backbuffer->pixels);
snprintf(text, sizeof(text), "FM Sound : %d", option.fm);
if (currentselection == 6) print_string(text, TextBlue, 0, 5, 87, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 87, backbuffer->pixels);
if (currentselection == 5) print_string(text, TextBlue, 0, 5, 75, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 75, backbuffer->pixels);
if (currentselection == 7) print_string("Reset", TextBlue, 0, 5, 99, backbuffer->pixels);
else print_string("Reset", TextWhite, 0, 5, 99, backbuffer->pixels);
if (currentselection == 6) print_string("Reset", TextBlue, 0, 5, 87, backbuffer->pixels);
else print_string("Reset", TextWhite, 0, 5, 87, backbuffer->pixels);
if (currentselection == 8) print_string("Quit", TextBlue, 0, 5, 111, backbuffer->pixels);
else print_string("Quit", TextWhite, 0, 5, 111, backbuffer->pixels);
if (currentselection == 7) print_string("Quit", TextBlue, 0, 5, 99, backbuffer->pixels);
else print_string("Quit", TextWhite, 0, 5, 99, backbuffer->pixels);
print_string("By gameblabla, ekeeke", TextWhite, 0, 5, 145, backbuffer->pixels);
@ -706,11 +688,11 @@ void Menu()
case SDLK_UP:
currentselection--;
if (currentselection == 0)
currentselection = 8;
currentselection = 7;
break;
case SDLK_DOWN:
currentselection++;
if (currentselection == 9)
if (currentselection == 8)
currentselection = 1;
break;
case SDLK_LCTRL:
@ -725,12 +707,7 @@ void Menu()
case 3:
if (save_slot > 0) save_slot--;
break;
case 4:
option.soundlevel--;
if (option.soundlevel < 1)
option.soundlevel = 4;
break;
case 6:
case 5:
if (option.fm > 0) option.fm--;
break;
}
@ -744,12 +721,7 @@ void Menu()
if (save_slot == 10)
save_slot = 9;
break;
case 4:
option.soundlevel++;
if (option.soundlevel > 4)
option.soundlevel = 1;
break;
case 6:
case 5:
if (option.fm < 1) option.fm++;
break;
}
@ -768,20 +740,15 @@ void Menu()
{
switch(currentselection)
{
case 7:
case 6:
//reset
Sound_Close();
Sound_Init();
system_poweron();
currentselection = 1;
break;
case 5:
Input_Remapping();
break;
case 4:
option.soundlevel++;
if (option.soundlevel > 4)
option.soundlevel = 1;
Input_Remapping();
break;
case 2 :
smsp_state(save_slot, 1);
@ -806,7 +773,7 @@ void Menu()
SDL_Flip(sdl_screen);
}
if (currentselection == 8)
if (currentselection == 7)
quit = 1;
}
@ -886,14 +853,10 @@ uint32_t update_window_size(uint32_t w, uint32_t h)
{
if (h == 0) h = 192;
#ifdef NOYUV
sdl_screen = SDL_SetVideoMode(w, h, 8, SDL_HWSURFACE | SDL_HWPALETTE);
sdl_screen = SDL_SetVideoMode(w, h, 8, SDL_HWSURFACE | SDL_TRIPLEBUF | SDL_HWPALETTE);
#else
sdl_screen = SDL_SetVideoMode(w, h, 24, SDL_HWSURFACE | SDL_YUV444);
sdl_screen = SDL_SetVideoMode(w, h, 24, SDL_HWSURFACE | SDL_TRIPLEBUF | SDL_YUV444 | SDL_ANYFORMAT | SDL_FULLSCREEN);
#endif
width_remember = w;
remember_res_height = h;
return 0;
}
@ -970,7 +933,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 8;
bitmap.granularity = 1;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -986,18 +948,26 @@ int main (int argc, char *argv[])
bios_init();
Sound_Init();
option.sndrate = SOUND_FREQUENCY;
// Initialize all systems and power on
system_poweron();
Sound_Init();
for(i = 0; i < PALETTE_SIZE; i += 1)
{
if(bitmap.pal.dirty[i])
{
#ifdef NOYUV
palette_8bpp[i].r = 0;
palette_8bpp[i].g = 0;
palette_8bpp[i].b = 0;
#else
drm_palette[0][i] = 0;
drm_palette[1][i] = 0;
drm_palette[2][i] = 0;
#endif
}
}
@ -1010,38 +980,36 @@ int main (int argc, char *argv[])
// Loop until the user closes the window
while (!quit)
{
// Execute frame(s)
system_frame(0);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();
input.system &= (IS_GG) ? ~INPUT_START : ~INPUT_PAUSE;
selectpressed = 0;
forcerefresh = 1;
}
if (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYUP:
sdl_controls_update_input(event.key.keysym.sym, 0);
sdl_controls_update_input_release(event.key.keysym.sym);
break;
case SDL_KEYDOWN:
sdl_controls_update_input(event.key.keysym.sym, 1);
if (event.key.keysym.sym == SDLK_ESCAPE)
{
Menu();
input.system &= (IS_GG) ? ~INPUT_START : ~INPUT_PAUSE;
forcerefresh = 1;
}
sdl_controls_update_input_down(event.key.keysym.sym);
break;
case SDL_QUIT:
quit = 1;
break;
}
}
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
}
config_save();

View File

@ -38,6 +38,9 @@ static const uint32_t upscalers_available = 1
+1
#endif
;
uint16_t real_FPS;
Uint32 start;
static void video_update(void)
{
@ -102,7 +105,9 @@ static void video_update(void)
}
SDL_UnlockSurface(sdl_screen);
}
SDL_Flip(sdl_screen);
if(real_FPS > SDL_GetTicks()-start) SDL_Delay(real_FPS-(SDL_GetTicks()-start));
}
void smsp_state(uint8_t slot_number, uint8_t mode)
@ -699,7 +704,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -713,24 +717,22 @@ int main (int argc, char *argv[])
sms.use_fm = 1;
}
bios_init();
if (sms.display == DISPLAY_PAL) real_FPS = 1000 / 50;
else real_FPS = 1000 / 60;
Sound_Init();
printf("sms.display %d, PAL is %d\n", sms.display, DISPLAY_PAL);
bios_init();
// Initialize all systems and power on
system_poweron();
Sound_Init();
// Loop until the user closes the window
while (!quit)
{
// Execute frame(s)
system_frame(0);
// Refresh video data
video_update();
// Output audio
Sound_Update();
start = SDL_GetTicks();
if (selectpressed == 1)
{
@ -755,6 +757,15 @@ int main (int argc, char *argv[])
break;
}
}
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
}
config_save();

View File

@ -626,7 +626,6 @@ int main (int argc, char *argv[])
bitmap.width = VIDEO_WIDTH_SMS;
bitmap.height = VIDEO_HEIGHT_SMS;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.data = (uint8_t *)sms_bitmap->pixels;
bitmap.pitch = sms_bitmap->pitch;
bitmap.viewport.w = VIDEO_WIDTH_SMS;
@ -649,12 +648,12 @@ int main (int argc, char *argv[])
// Execute frame(s)
system_frame(0);
// Refresh sound data
Sound_Update(snd.output, snd.sample_count);
// Refresh video data
video_update();
// Output audio
Sound_Update();
if (selectpressed == 1)
{
Menu();

View File

@ -401,7 +401,6 @@ void render_line(int32_t line)
/* Sprites are still processed offscreen */
if ((vdp.mode > 7) && (vdp.reg[1] & 0x40))
render_obj(line);
/* Line is only displayed where overscan is emulated */
view = 0;
}

View File

@ -63,7 +63,7 @@ void upscale_160x144_to_240x160(uint16_t* restrict src, uint16_t* restrict dst){
uint16_t c[3][10];
//stretch 2px to 3px(horizonal)
for(int i=0; i<10; i++){
uint16_t r0,r1,g0,g1,b1,b2;
uint16_t r0,g0,g1,b1;
c[0][i] = buffer_mem[x + i * 256];
r0 = buffer_mem[x + i * 256] & RMASK;
g0 = buffer_mem[x + i * 256] & GMASK;

View File

@ -126,10 +126,9 @@ uint32_t SMSPLUS_sound_init(void)
}
/* Allocate sound output streams */
snd.output[0] = malloc(snd.buffer_size);
snd.output[1] = malloc(snd.buffer_size);
snd.output = malloc(snd.buffer_size*2);
if(!snd.output[0] || !snd.output[1])
if(!snd.output)
return 0;
/* Set up buffer pointers */
@ -187,13 +186,10 @@ void SMSPLUS_sound_shutdown(void)
}
/* Free sound output buffers */
for(i = 0; i < 2; i++)
if(snd.output)
{
if(snd.output[i])
{
free(snd.output[i]);
snd.output[i] = NULL;
}
free(snd.output);
snd.output = NULL;
}
/* Free sample buffer position table if previously allocated */
@ -288,14 +284,14 @@ void SMSPLUS_sound_update(int32_t line)
}
/* Generic FM+PSG stereo mixer callback */
void SMSPLUS_sound_mixer_callback(int16_t **output, int32_t length)
void SMSPLUS_sound_mixer_callback(int16_t *output, int32_t length)
{
int32_t i;
for(i = 0; i < length; i++)
{
int16_t temp = (fm_buffer[0][i] + fm_buffer[1][i]) / 2;
output[0][i] = temp + psg_buffer[0][i];
output[1][i] = temp + psg_buffer[1][i];
output[i * 2] = temp + psg_buffer[0][i];
output[i * 2 + 1] = temp + psg_buffer[1][i];
}
}

View File

@ -36,8 +36,8 @@ enum {
/* Sound emulation structure */
typedef struct
{
void (*mixer_callback)(int16_t **output, int32_t length);
int16_t *output[2];
void (*mixer_callback)(int16_t *output, int32_t length);
int16_t *output;
int16_t *stream[STREAM_MAX];
int32_t fm_which;
int32_t enabled;
@ -64,6 +64,6 @@ uint32_t SMSPLUS_sound_init(void);
void SMSPLUS_sound_shutdown(void);
void SMSPLUS_sound_reset(void);
void SMSPLUS_sound_update(int32_t line);
void SMSPLUS_sound_mixer_callback(int16_t **output, int32_t length);
void SMSPLUS_sound_mixer_callback(int16_t *output, int32_t length);
#endif /* SOUND_H_ */

View File

@ -12,7 +12,6 @@
#include "shared.h"
static snd_pcm_t *handle;
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
void Sound_Init(void)
{
@ -21,8 +20,6 @@ void Sound_Init(void)
int32_t dir = -1;
snd_pcm_uframes_t frames;
option.sndrate = SOUND_FREQUENCY;
/* Open PCM device for playback. */
int32_t rc = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
@ -51,6 +48,8 @@ void Sound_Init(void)
#ifdef NONBLOCKING_AUDIO
snd_pcm_nonblock(handle, 1);
#else
snd_pcm_nonblock(handle, 0);
#endif
/* Allocate a hardware parameters object. */
@ -90,7 +89,7 @@ void Sound_Init(void)
return;
}
val = SOUND_FREQUENCY;
val = snd.sample_rate;
rc=snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir);
if (rc < 0)
{
@ -99,7 +98,7 @@ void Sound_Init(void)
}
/* Set period size to settings.aica.BufferSize frames. */
frames = SOUND_SAMPLES_SIZE;
frames = snd.buffer_size;
rc = snd_pcm_hw_params_set_period_size_near(handle, params, &frames, &dir);
if (rc < 0)
{
@ -122,28 +121,19 @@ void Sound_Init(void)
return;
}
return;
}
void Sound_Update(void)
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
uint32_t i;
long len = SOUND_FREQUENCY / snd.fps, ret;
if (!handle) return;
for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
ret = snd_pcm_writei(handle, buffer_snd, len);
long ret;
ret = snd_pcm_writei(handle, sound_buffer, len);
while(ret != len)
{
if (ret < 0) snd_pcm_prepare( handle );
else len -= ret;
ret = snd_pcm_writei(handle, buffer_snd, len);
ret = snd_pcm_writei(handle, sound_buffer, len);
}
}

View File

@ -14,7 +14,6 @@
static ao_device *aodevice;
static ao_sample_format aoformat;
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
void Sound_Init()
{
@ -23,25 +22,17 @@ void Sound_Init()
aoformat.bits = 16;
aoformat.channels = 2;
aoformat.rate = SOUND_FREQUENCY;
aoformat.rate = option.sndrate;
aoformat.byte_format = AO_FMT_LITTLE;
option.sndrate = SOUND_FREQUENCY;
aodevice = ao_open_live(ao_default_driver_id(), &aoformat, NULL); // Live output
if (!aodevice)
aodevice = ao_open_live(ao_driver_id("null"), &aoformat, NULL);
}
void Sound_Update()
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
int32_t i;
for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
ao_play(aodevice, (char*)buffer_snd, SOUND_FREQUENCY / snd.fps);
ao_play(aodevice, (char*)sound_buffer, len);
}
void Sound_Close()

View File

@ -15,19 +15,16 @@
#include "shared.h"
static int32_t oss_audio_fd = -1;
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
void Sound_Init()
{
uint32_t channels = 2;
uint32_t format = AFMT_S16_LE;
uint32_t tmp = SOUND_FREQUENCY;
int32_t err_ret;
option.sndrate = SOUND_FREQUENCY;
tmp = option.sndrate;
oss_audio_fd = open("/dev/dsp", O_WRONLY
/* Probably shouldn't be used now ? */
#ifdef NONBLOCKING_AUDIO
| O_NONBLOCK
#endif
@ -60,18 +57,10 @@ void Sound_Init()
return;
}
void Sound_Update()
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
int32_t i;
if (!oss_audio_fd) return;
for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
write(oss_audio_fd, buffer_snd, 4 * (SOUND_FREQUENCY / snd.fps) );
write(oss_audio_fd, sound_buffer, len);
}
void Sound_Close()

View File

@ -13,7 +13,6 @@
#include "shared.h"
PaStream *apu_stream;
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
#ifdef NONBLOCKING_AUDIO
static int patestCallback( const void *inputBuffer, void *outputBuffer,
@ -23,16 +22,9 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
void *userData )
{
/* Cast data passed through stream to our structure. */
uint16_t *out = (uint16_t*)outputBuffer;
int32_t i;
uint16_t *out = (uint16_t*)snd.output;
(void) inputBuffer; /* Prevent unused variable warning. */
for (i = 0; i < ( (SOUND_FREQUENCY / snd.fps)); i++)
{
out[i * 2] = snd.output[1][i] * option.soundlevel;
out[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
return 0;
}
#endif
@ -44,8 +36,6 @@ void Sound_Init()
PaStreamParameters outputParameters;
option.sndrate = SOUND_FREQUENCY;
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice)
@ -59,7 +49,7 @@ void Sound_Init()
//outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream( &apu_stream, NULL, &outputParameters, SOUND_FREQUENCY, SOUND_SAMPLES_SIZE, paNoFlag,
err = Pa_OpenStream( &apu_stream, NULL, &outputParameters, option.sndrate, snd.buffer_size, paNoFlag,
#ifdef NONBLOCKING_AUDIO
patestCallback, NULL);
#else
@ -68,16 +58,10 @@ void Sound_Init()
err = Pa_StartStream( apu_stream );
}
void Sound_Update()
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
#ifndef NONBLOCKING_AUDIO
int32_t i;
for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
Pa_WriteStream( apu_stream, buffer_snd, SOUND_FREQUENCY / snd.fps );
Pa_WriteStream( apu_stream, sound_buffer, len);
#endif
}

View File

@ -15,16 +15,13 @@
#include "shared.h"
static pa_simple *pulse_stream;
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
void Sound_Init()
{
pa_sample_spec ss;
ss.format = PA_SAMPLE_S16LE;
ss.channels = 2;
ss.rate = SOUND_FREQUENCY;
option.sndrate = SOUND_FREQUENCY;
ss.rate = option.sndrate;
/* Create a new playback stream */
pulse_stream = pa_simple_new(NULL, "smsplusgx", PA_STREAM_PLAYBACK, NULL, "smsplusgx", &ss, NULL, NULL, NULL);
@ -35,16 +32,9 @@ void Sound_Init()
return;
}
void Sound_Update()
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
size_t i;
size_t len = (SOUND_FREQUENCY / snd.fps);
for (i = 0; i < len; i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
if (pa_simple_write(pulse_stream, buffer_snd, len * 4, NULL) < 0)
if (pa_simple_write(pulse_stream, sound_buffer, len, NULL) < 0)
{
fprintf(stderr, "PulseAudio: pa_simple_write() failed!\n");
}

View File

@ -7,9 +7,8 @@
/* Most of the sound code was taken from FBA-SDL by DmitrySmagin so many thanks to him ! */
static int16_t buffer_snd[SOUND_FREQUENCY * 2];
SDL_mutex *sound_mutex;
SDL_cond *sound_cv;
static SDL_mutex *sound_mutex;
static SDL_cond *sound_cv;
/* Using Mutexes by default but allowing disabling them on compilation */
#ifdef SDLAUDIO_NOMUTEXES
@ -24,7 +23,7 @@ static uint32_t buf_read_pos = 0;
static uint32_t buf_write_pos = 0;
static int32_t buffered_bytes = 0;
static int32_t sdl_write_buffer_m(uint8_t* data, int32_t len)
static int32_t sdl_write_buffer_m(uint8_t* data, unsigned long len)
{
SDL_LockMutex(sound_mutex);
for(uint8_t i = 0; i < len; i += 4)
@ -92,9 +91,8 @@ void sdl_callback(void *unused, uint8_t *stream, int32_t len)
void Sound_Init()
{
SDL_AudioSpec aspec, obtained;
option.sndrate = SOUND_FREQUENCY;
BUFFSIZE = SOUND_SAMPLES_SIZE * 2 * 2 * 8;
BUFFSIZE = snd.buffer_size * 2 * 2 * 8;
buffer = (uint8_t *) malloc(BUFFSIZE);
/* Add some silence to the buffer */
@ -102,10 +100,10 @@ void Sound_Init()
buf_read_pos = 0;
buf_write_pos = 0;
aspec.format = AUDIO_S16;
aspec.freq = SOUND_FREQUENCY;
aspec.format = AUDIO_S16SYS;
aspec.freq = option.sndrate;
aspec.channels = 2;
aspec.samples = SOUND_SAMPLES_SIZE;
aspec.samples = snd.buffer_size;
aspec.callback = (mutex ? sdl_callback_m : sdl_callback);
aspec.userdata = NULL;
@ -135,17 +133,10 @@ void Sound_Init()
return;
}
void Sound_Update()
void Sound_Update(int16_t* sound_buffer, unsigned long len)
{
int32_t i;
for (i = 0; i < (SOUND_FREQUENCY / snd.fps); i++)
{
buffer_snd[i * 2] = snd.output[1][i] * option.soundlevel;
buffer_snd[i * 2 + 1] = snd.output[0][i] * option.soundlevel;
}
SDL_LockAudio();
sdl_write_buffer((int16_t*)buffer_snd, (SOUND_FREQUENCY / snd.fps));
sdl_write_buffer(sound_buffer, len);
SDL_UnlockAudio();
}

View File

@ -1,8 +1,11 @@
#ifndef SOUND_OUTPUT_H
#define SOUND_OUTPUT_H
#include <stdint.h>
extern void Sound_Init(void);
extern void Sound_Update(void);
//extern void Sound_Update(void);
extern void Sound_Update(int16_t* sound_buffer, unsigned long len);
extern void Sound_Close(void);
#endif

View File

@ -144,6 +144,6 @@ void system_load_state(FILE* fd)
}
/* Restore palette */
for(uint32_t i = 0; i < PALETTE_SIZE; i++)
for(int32_t i = 0; i < PALETTE_SIZE; i++)
palette_sync(i);
}

View File

@ -82,7 +82,6 @@ typedef struct
uint32_t height;
uint32_t pitch;
uint32_t depth;
uint32_t granularity;
struct
{
int32_t x, y, w, h;

View File

@ -91,11 +91,11 @@ static void drawChar(uint16_t* restrict buffer, int32_t *x, int32_t *y, int32_t
{
if((charSprite[i] >> j) & 1)
{
setPixel(buffer, *x + (7 - j), *y + i, fc);
setPixel(buffer, *x + (7 - j), *y + i, fc)
}
else if(isOutlinePixel(charSprite, 7 - j, i))
{
setPixel(buffer, *x + (7 - j), *y + i, olc);
setPixel(buffer, *x + (7 - j), *y + i, olc)
}
}
}

View File

@ -309,23 +309,12 @@ void make_tms_tables(void)
uint8_t bs = (bx & 0x40);
// uint8_t bt = (bd == 0) ? 1 : 0;
uint8_t sd = (sx & 0x0F);
// uint8_t st = (sd == 0) ? 1 : 0;
// opaque sprite pixel, choose 2nd pal and set sprite marker
if(sd && !bs)
{
tms_obj_lut[(sx<<8)|(bx)] = sd | 0x10 | 0x40;
}
else
if(sd && bs)
{
// writing over a sprite
tms_obj_lut[(sx<<8)|(bx)] = bx;
}
else
{
tms_obj_lut[(sx<<8)|(bx)] = bx;
}
tms_obj_lut[(sx<<8)|(bx)] = bx;
}
}

View File

@ -1039,8 +1039,6 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
/* ZIP64 extra fields */
if (headerId == 0x0001)
{
uLong uL;
if(file_info.uncompressed_size == MAXU32)
{
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)