diff --git a/bin/CHIP84.8xp b/bin/CHIP84.8xp index dbea170..0e8f1c9 100644 Binary files a/bin/CHIP84.8xp and b/bin/CHIP84.8xp differ diff --git a/bin/CHIP84.bin b/bin/CHIP84.bin index 091b72c..bbf6e6e 100644 Binary files a/bin/CHIP84.bin and b/bin/CHIP84.bin differ diff --git a/bin/CHIP84.dbg b/bin/CHIP84.dbg index d600028..2f64fd2 100644 Binary files a/bin/CHIP84.dbg and b/bin/CHIP84.dbg differ diff --git a/bin/Chip-84.zip b/bin/Chip-84.zip index d34817e..627ad9b 100644 Binary files a/bin/Chip-84.zip and b/bin/Chip-84.zip differ diff --git a/obj/canvas.src b/obj/canvas.src index fa0b7c3..1e1b187 100644 --- a/obj/canvas.src +++ b/obj/canvas.src @@ -4,31 +4,4 @@ FILE "..\SRC\CANVAS.C" .assume ADL=1 .DEBUG "C" - SEGMENT BSS -_canvas_data: - DS 2050 -.DEFINE "canvas_data" -.ALIAS "_canvas_data" -.CLASS 83 -.VALUE _canvas_data -.DIM 2050 -.TYPE 108 -.ENDEF -_scanvas_data: - DS 8194 -.DEFINE "scanvas_data" -.ALIAS "_scanvas_data" -.CLASS 83 -.VALUE _scanvas_data -.DIM 8194 -.TYPE 108 -.ENDEF - XDEF _scanvas_data - XDEF _canvas_data -; 1 // Converted using ConvPNG -; 2 #include -; 3 #include "sprites_gfx.h" -; 4 -; 5 // 8 bpp image -; 6 uint8_t canvas_data[2050]; END diff --git a/obj/chip8.src b/obj/chip8.src index c61e700..3a23cbf 100644 --- a/obj/chip8.src +++ b/obj/chip8.src @@ -409,6 +409,14 @@ _extendedScreen: .CLASS 69 .VALUE _extendedScreen .TYPE 12 +.ENDEF +_plane: + DB 1 +.DEFINE "plane" +.ALIAS "_plane" +.CLASS 69 +.VALUE _plane +.TYPE 12 .ENDEF SEGMENT BSS _game_data: @@ -420,6 +428,15 @@ _game_data: .DIM 3584 .TYPE 108 .ENDEF +_canvas_data: + DS 8194 +.DEFINE "canvas_data" +.ALIAS "_canvas_data" +.CLASS 83 +.VALUE _canvas_data +.DIM 8194 +.TYPE 108 +.ENDEF _keypad: DS 16 .DEFINE "keypad" @@ -680,95 +697,105 @@ _screen_height: .VALUE _screen_height .TYPE 12 .ENDEF +_pixel_number: + DS 1 +.DEFINE "pixel_number" +.ALIAS "_pixel_number" +.CLASS 83 +.VALUE _pixel_number +.TYPE 12 +.ENDEF ; 1 #include ; 2 #include ; 3 #include ; 4 #include -; 5 #include -; 6 -; 7 #include -; 8 #include -; 9 #include -; 10 #include -; 11 -; 12 #include -; 13 #include -; 14 -; 15 #include "chip8.h" -; 16 #include "sprites_gfx.h" -; 17 -; 18 uint16_t opcode = 0; -; 19 uint8_t memory[4096]; -; 20 uint8_t SV[8]; -; 21 uint8_t V[16]; -; 22 uint16_t I = 0; -; 23 uint16_t pc = 0; -; 24 int16_t delay_timer = 0; -; 25 int16_t sound_timer = 0; -; 26 uint16_t stack[16]; -; 27 uint8_t sp = 0; -; 28 uint8_t keys[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -; 29 bool drawFlag = false; -; 30 -; 31 bool paused = false; -; 32 bool playing = false; -; 33 bool extendedScreen = 0; +; 5 +; 6 #include +; 7 #include +; 8 #include +; 9 #include +; 10 +; 11 #include +; 12 #include +; 13 +; 14 #include "chip8.h" +; 15 #include "sprites_gfx.h" +; 16 +; 17 uint16_t opcode = 0; +; 18 uint8_t memory[0x1000]; +; 19 uint8_t SV[8]; +; 20 uint8_t V[16]; +; 21 uint16_t I = 0; +; 22 uint16_t pc = 0; +; 23 int16_t delay_timer = 0; +; 24 int16_t sound_timer = 0; +; 25 uint16_t stack[16]; +; 26 uint8_t sp = 0; +; 27 uint8_t keys[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +; 28 bool drawFlag = false; +; 29 +; 30 bool paused = false; +; 31 bool playing = false; +; 32 bool extendedScreen = 0; +; 33 uint8_t plane = 1; ; 34 ; 35 uint8_t game_data[3584]; -; 36 uint8_t keypad[16]; -; 37 uint8_t controlMap[16]; -; 38 -; 39 ti_var_t file; -; 40 -; 41 unsigned char fontset[80] = { -; 42 0xF0, 0x90, 0x90, 0x90, 0xF0, //0 -; 43 0x20, 0x60, 0x20, 0x20, 0x70, //1 -; 44 0xF0, 0x10, 0xF0, 0x80, 0xF0, //2 -; 45 0xF0, 0x10, 0xF0, 0x10, 0xF0, //3 -; 46 0x90, 0x90, 0xF0, 0x10, 0x10, //4 -; 47 0xF0, 0x80, 0xF0, 0x10, 0xF0, //5 -; 48 0xF0, 0x80, 0xF0, 0x90, 0xF0, //6 -; 49 0xF0, 0x10, 0x20, 0x40, 0x40, //7 -; 50 0xF0, 0x90, 0xF0, 0x90, 0xF0, //8 -; 51 0xF0, 0x90, 0xF0, 0x10, 0xF0, //9 -; 52 0xF0, 0x90, 0xF0, 0x90, 0x90, //A -; 53 0xE0, 0x90, 0xE0, 0x90, 0xE0, //B -; 54 0xF0, 0x80, 0x80, 0x80, 0xF0, //C -; 55 0xE0, 0x90, 0x90, 0x90, 0xE0, //D -; 56 0xF0, 0x80, 0xF0, 0x80, 0xF0, //E -; 57 0xF0, 0x80, 0xF0, 0x80, 0x80 //F -; 58 }; -; 59 uint16_t fontset_ten[80] = { -; 60 0xC67C, 0xDECE, 0xF6D6, 0xC6E6, 0x007C, // 0 -; 61 0x3010, 0x30F0, 0x3030, 0x3030, 0x00FC, // 1 -; 62 0xCC78, 0x0CCC, 0x3018, 0xCC60, 0x00FC, // 2 -; 63 0xCC78, 0x0C0C, 0x0C38, 0xCC0C, 0x0078, // 3 -; 64 0x1C0C, 0x6C3C, 0xFECC, 0x0C0C, 0x001E, // 4 -; 65 0xC0FC, 0xC0C0, 0x0CF8, 0xCC0C, 0x0078, // 5 -; 66 0x6038, 0xC0C0, 0xCCF8, 0xCCCC, 0x0078, // 6 -; 67 0xC6FE, 0x06C6, 0x180C, 0x3030, 0x0030, // 7 -; 68 0xCC78, 0xECCC, 0xDC78, 0xCCCC, 0x0078, // 8 -; 69 0xC67C, 0xC6C6, 0x0C7E, 0x3018, 0x0070, // 9 -; 70 0x7830, 0xCCCC, 0xFCCC, 0xCCCC, 0x00CC, // A -; 71 0x66FC, 0x6666, 0x667C, 0x6666, 0x00FC, // B -; 72 0x663C, 0xC0C6, 0xC0C0, 0x66C6, 0x003C, // C -; 73 0x6CF8, 0x6666, 0x6666, 0x6C66, 0x00F8, // D -; 74 0x62FE, 0x6460, 0x647C, 0x6260, 0x00FE, // E -; 75 0x66FE, 0x6462, 0x647C, 0x6060, 0x00F0 // F -; 76 }; -; 77 -; 78 uint8_t step; -; 79 uint16_t pixel; -; 80 uint16_t index; -; 81 -; 82 uint8_t _y; -; 83 uint8_t _x; -; 84 -; 85 uint8_t screen_width; -; 86 uint8_t screen_height; +; 36 uint8_t canvas_data[8194]; +; 37 uint8_t keypad[16]; +; 38 uint8_t controlMap[16]; +; 39 +; 40 ti_var_t file; +; 41 +; 42 unsigned char fontset[80] = { +; 43 0xF0, 0x90, 0x90, 0x90, 0xF0, //0 +; 44 0x20, 0x60, 0x20, 0x20, 0x70, //1 +; 45 0xF0, 0x10, 0xF0, 0x80, 0xF0, //2 +; 46 0xF0, 0x10, 0xF0, 0x10, 0xF0, //3 +; 47 0x90, 0x90, 0xF0, 0x10, 0x10, //4 +; 48 0xF0, 0x80, 0xF0, 0x10, 0xF0, //5 +; 49 0xF0, 0x80, 0xF0, 0x90, 0xF0, //6 +; 50 0xF0, 0x10, 0x20, 0x40, 0x40, //7 +; 51 0xF0, 0x90, 0xF0, 0x90, 0xF0, //8 +; 52 0xF0, 0x90, 0xF0, 0x10, 0xF0, //9 +; 53 0xF0, 0x90, 0xF0, 0x90, 0x90, //A +; 54 0xE0, 0x90, 0xE0, 0x90, 0xE0, //B +; 55 0xF0, 0x80, 0x80, 0x80, 0xF0, //C +; 56 0xE0, 0x90, 0x90, 0x90, 0xE0, //D +; 57 0xF0, 0x80, 0xF0, 0x80, 0xF0, //E +; 58 0xF0, 0x80, 0xF0, 0x80, 0x80 //F +; 59 }; +; 60 uint16_t fontset_ten[80] = { +; 61 0xC67C, 0xDECE, 0xF6D6, 0xC6E6, 0x007C, // 0 +; 62 0x3010, 0x30F0, 0x3030, 0x3030, 0x00FC, // 1 +; 63 0xCC78, 0x0CCC, 0x3018, 0xCC60, 0x00FC, // 2 +; 64 0xCC78, 0x0C0C, 0x0C38, 0xCC0C, 0x0078, // 3 +; 65 0x1C0C, 0x6C3C, 0xFECC, 0x0C0C, 0x001E, // 4 +; 66 0xC0FC, 0xC0C0, 0x0CF8, 0xCC0C, 0x0078, // 5 +; 67 0x6038, 0xC0C0, 0xCCF8, 0xCCCC, 0x0078, // 6 +; 68 0xC6FE, 0x06C6, 0x180C, 0x3030, 0x0030, // 7 +; 69 0xCC78, 0xECCC, 0xDC78, 0xCCCC, 0x0078, // 8 +; 70 0xC67C, 0xC6C6, 0x0C7E, 0x3018, 0x0070, // 9 +; 71 0x7830, 0xCCCC, 0xFCCC, 0xCCCC, 0x00CC, // A +; 72 0x66FC, 0x6666, 0x667C, 0x6666, 0x00FC, // B +; 73 0x663C, 0xC0C6, 0xC0C0, 0x66C6, 0x003C, // C +; 74 0x6CF8, 0x6666, 0x6666, 0x6C66, 0x00F8, // D +; 75 0x62FE, 0x6460, 0x647C, 0x6260, 0x00FE, // E +; 76 0x66FE, 0x6462, 0x647C, 0x6060, 0x00F0 // F +; 77 }; +; 78 +; 79 uint8_t step; +; 80 uint16_t pixel; +; 81 uint16_t index; +; 82 +; 83 uint8_t _y; +; 84 uint8_t _x; +; 85 +; 86 uint8_t screen_width; +; 87 uint8_t screen_height; +; 88 uint8_t pixel_number; SEGMENT CODE -; 87 -; 88 void initialize() { +; 89 +; 90 void initialize() { _initialize: .DEFINE "_initialize" @@ -780,14 +807,14 @@ _initialize: .ENDEF -.BEGFUNC "initialize",88,"_initialize" +.BEGFUNC "initialize",90,"_initialize" PUSH IX LD IX,0 ADD IX,SP -; 89 -; 90 opcode = I = sp = delay_timer = sound_timer = 0; -.LINE 90 +; 91 +; 92 opcode = I = sp = delay_timer = sound_timer = 0; +.LINE 92 LD HL,_sound_timer LD (HL),0 @@ -807,70 +834,45 @@ _initialize: LD (HL),0 INC HL LD (HL),0 -; 91 pc = 0x200; -.LINE 91 +; 93 pc = 0x200; +.LINE 93 LD HL,_pc LD (HL),0 INC HL LD (HL),2 -; 92 -; 93 extendedScreen = 0; -.LINE 93 +; 94 +; 95 extendedScreen = 0; +.LINE 95 XOR A,A LD (_extendedScreen),A -; 94 screen_width = 64; -.LINE 94 +; 96 screen_width = 64; +.LINE 96 LD A,64 LD (_screen_width),A -; 95 screen_height = 32; -.LINE 95 +; 97 screen_height = 32; +.LINE 97 LD A,32 LD (_screen_height),A -; 96 -; 97 scanvas_data[0] = 128; -.LINE 97 - - LD A,128 - LD (_scanvas_data),A -; 98 scanvas_data[1] = 64; -.LINE 98 - - LD HL,_scanvas_data - INC HL - LD (HL),64 -; 99 memset(scanvas_data + 2, 0, 8192); +; 98 +; 99 canvas_data[0] = 64; .LINE 99 - LD BC,8192 - PUSH BC - LD BC,0 - PUSH BC - LD BC,_scanvas_data+2 - PUSH BC - CALL _memset - POP BC - POP BC - POP BC -; 100 -; 101 canvas_data[0] = 64; -.LINE 101 - LD A,64 LD (_canvas_data),A -; 102 canvas_data[1] = 32; -.LINE 102 +; 100 canvas_data[1] = 32; +.LINE 100 LD HL,_canvas_data INC HL LD (HL),32 -; 103 memset(canvas_data + 2, 0, 2048); -.LINE 103 +; 101 memset(canvas_data + 2, 0, 8192); +.LINE 101 - LD BC,2048 + LD BC,8192 PUSH BC LD BC,0 PUSH BC @@ -880,9 +882,9 @@ _initialize: POP BC POP BC POP BC -; 104 -; 105 memset(keys, 0, 16); -.LINE 105 +; 102 +; 103 memset(keys, 0, 16); +.LINE 103 LD BC,16 PUSH BC @@ -894,8 +896,8 @@ _initialize: POP BC POP BC POP BC -; 106 memset(stack, 0, 16); -.LINE 106 +; 104 memset(stack, 0, 16); +.LINE 104 LD BC,16 PUSH BC @@ -907,8 +909,8 @@ _initialize: POP BC POP BC POP BC -; 107 memset(V, 0, 16); -.LINE 107 +; 105 memset(V, 0, 16); +.LINE 105 LD BC,16 PUSH BC @@ -920,8 +922,8 @@ _initialize: POP BC POP BC POP BC -; 108 memset(SV, 0, 8); -.LINE 108 +; 106 memset(SV, 0, 8); +.LINE 106 LD BC,8 PUSH BC @@ -933,8 +935,8 @@ _initialize: POP BC POP BC POP BC -; 109 memset(memory, 0, 4096); -.LINE 109 +; 107 memset(memory, 0, 4096); +.LINE 107 LD BC,4096 PUSH BC @@ -946,9 +948,9 @@ _initialize: POP BC POP BC POP BC -; 110 -; 111 memcpy(memory, fontset, 80); -.LINE 111 +; 108 +; 109 memcpy(memory, fontset, 80); +.LINE 109 LD BC,80 PUSH BC @@ -960,8 +962,8 @@ _initialize: POP BC POP BC POP BC -; 112 memcpy(memory + 80, fontset_ten, 80); -.LINE 112 +; 110 memcpy(memory + 80, fontset_ten, 80); +.LINE 110 LD BC,80 PUSH BC @@ -973,16 +975,16 @@ _initialize: POP BC POP BC POP BC -; 113 -; 114 srand(rtc_Time()); -.LINE 114 +; 111 +; 112 srand(rtc_Time()); +.LINE 112 LD BC,(15925316) PUSH BC CALL _srand POP BC -; 115 } -.LINE 115 +; 113 } +.LINE 113 LD SP,IX POP IX @@ -1000,9 +1002,8 @@ _initialize: ;_V STATIC 16 variable ;_stack STATIC 32 variable ;_keys STATIC 16 variable -;_canvas_data IMPORT 2050 variable ;_memset IMPORT ----- function -;_scanvas_data IMPORT 8194 variable +;_canvas_data STATIC 8194 variable ;_screen_height STATIC 1 variable ;_screen_width STATIC 1 variable ;_extendedScreen STATIC 1 variable @@ -1018,9 +1019,9 @@ _initialize: ; Spill Code: 0 (instruction) -.ENDFUNC "initialize",115,"_initialize" -; 116 -; 117 void loadProgram(char *fileName) { +.ENDFUNC "initialize",113,"_initialize" +; 114 +; 115 void loadProgram(char *fileName) { _loadProgram: .DEFINE "_loadProgram" @@ -1032,9 +1033,9 @@ _loadProgram: .ENDEF -.BEGFUNC "loadProgram",117,"_loadProgram" +.BEGFUNC "loadProgram",115,"_loadProgram" -.LINE 117 +.LINE 115 .DEFINE "fileName" @@ -1072,26 +1073,26 @@ _loadProgram: PUSH BC DEC SP DEC SP -; 118 int i; -; 119 uint16_t romSize; -; 120 -; 121 playing = true; -.LINE 121 +; 116 int i; +; 117 uint16_t romSize; +; 118 +; 119 playing = true; +.LINE 119 LD A,1 LD (_playing),A -; 122 paused = false; -.LINE 122 +; 120 paused = false; +.LINE 120 XOR A,A LD (_paused),A -; 123 -; 124 ti_CloseAll(); -.LINE 124 +; 121 +; 122 ti_CloseAll(); +.LINE 122 CALL _ti_CloseAll -; 125 file = ti_Open(fileName, "r"); -.LINE 125 +; 123 file = ti_Open(fileName, "r"); +.LINE 123 LD BC,L__1 PUSH BC @@ -1101,8 +1102,8 @@ _loadProgram: POP BC POP BC LD (_file),A -; 126 ti_Read(&game_data, ti_GetSize(file), 1, file); -.LINE 126 +; 124 ti_Read(&game_data, ti_GetSize(file), 1, file); +.LINE 124 LD C,A LD B,0 @@ -1124,9 +1125,9 @@ _loadProgram: POP BC POP BC POP BC -; 127 -; 128 romSize = ti_GetSize(file)-(16+6); -.LINE 128 +; 125 +; 126 romSize = ti_GetSize(file)-22; +.LINE 126 LD A,(_file) LD C,A @@ -1138,14 +1139,14 @@ _loadProgram: LEA HL,IY+-22 LD (IX+-5),L LD (IX+-4),H -; 129 -; 130 initialize(); -.LINE 130 +; 127 +; 128 initialize(); +.LINE 128 CALL _initialize -; 131 -; 132 if((4096-512) > romSize) { -.LINE 132 +; 129 +; 130 if((4096-512) > romSize) { +.LINE 130 LD BC,(IX+-5) CALL __stoiu @@ -1154,15 +1155,15 @@ _loadProgram: SBC HL,BC CALL __setflag JP P,L_9 -; 133 for(i = 0; i < romSize; ++i) { -.LINE 133 +; 131 for(i = 0; i < romSize; ++i) { +.LINE 131 LD BC,0 LD (IX+-3),BC JR L_3 L_1: -; 134 memory[i + 512] = (uint8_t)game_data[i+16+6]; -.LINE 134 +; 132 memory[i + 512] = (uint8_t)game_data[i+22]; +.LINE 132 LD IY,(IX+-3) LEA HL,IY+22 @@ -1179,9 +1180,9 @@ L_1: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 135 } +; 133 } L_3: -.LINE 135 +.LINE 133 LD BC,(IX+-5) CALL __stoiu @@ -1191,19 +1192,19 @@ L_3: SBC HL,BC CALL __setflag JP M,L_1 -; 136 } +; 134 } L_9: -.LINE 136 +.LINE 134 -; 137 for(i = 0; i < 16; i++) { -.LINE 137 +; 135 for(i = 0; i < 16; i++) { +.LINE 135 LD BC,0 LD (IX+-3),BC JR L_8 L_6: -; 138 controlMap[i] = (uint8_t)game_data[i+6]; -.LINE 138 +; 136 controlMap[i] = (uint8_t)game_data[i+6]; +.LINE 136 LD IY,(IX+-3) LEA HL,IY+6 @@ -1218,9 +1219,9 @@ L_6: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 139 } +; 137 } L_8: -.LINE 139 +.LINE 137 LD BC,16 LD HL,(IX+-3) @@ -1228,8 +1229,8 @@ L_8: SBC HL,BC CALL __setflag JP M,L_6 -; 140 } -.LINE 140 +; 138 } +.LINE 138 LD SP,IX POP IX @@ -1258,14 +1259,14 @@ L_8: ; Spill Code: 0 (instruction) -.ENDFUNC "loadProgram",140,"_loadProgram" +.ENDFUNC "loadProgram",138,"_loadProgram" SEGMENT STRSECT L__1: DB "r" DB 0 SEGMENT CODE -; 141 -; 142 void setKeys() { +; 139 +; 140 void setKeys() { _setKeys: .DEFINE "_setKeys" @@ -1277,11 +1278,26 @@ _setKeys: .ENDEF -.BEGFUNC "setKeys",142,"_setKeys" +.BEGFUNC "setKeys",140,"_setKeys" + +.LINE 140 + +.DEFINE "i" + +.CLASS 65 + +.VALUE -1 + +.TYPE 12 + +.ENDEF PUSH IX LD IX,0 ADD IX,SP + DEC SP +; 141 uint8_t i; +; 142 ; 143 keypad[0x0] = kb_Data[4] & kb_DecPnt; .LINE 143 @@ -1393,206 +1409,76 @@ _setKeys: LD A,(16056348) AND A,1 - LD HL,_keypad+15 + LEA HL,IY+15 LD (HL),A ; 159 -; 160 keys[0x0] = keypad[controlMap[0x0]]; +; 160 for(i = 0; i < 15; i++) { .LINE 160 - LD A,(_controlMap) - UEXT HL - LD L,A - LD BC,_keypad - ADD HL,BC - LD A,(HL) - LD (_keys),A -; 161 keys[0x1] = keypad[controlMap[0x1]]; + LD (IX+-1),0 + JR L_14 +L_12: +; 161 keys[i] = keypad[controlMap[i]]; .LINE 161 - LD HL,_controlMap - INC HL - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD IY,_keys - LD A,(HL) - LD (IY+1),A -; 162 keys[0x2] = keypad[controlMap[0x2]]; -.LINE 162 - - LD HL,_controlMap+2 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+2),A -; 163 keys[0x3] = keypad[controlMap[0x3]]; -.LINE 163 - - LD HL,_controlMap+3 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+3),A -; 164 -; 165 keys[0x4] = keypad[controlMap[0x4]]; -.LINE 165 - - LD HL,_controlMap+4 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+4),A -; 166 keys[0x5] = keypad[controlMap[0x5]]; -.LINE 166 - - LD HL,_controlMap+5 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+5),A -; 167 keys[0x6] = keypad[controlMap[0x6]]; -.LINE 167 - - LD HL,_controlMap+6 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+6),A -; 168 keys[0x7] = keypad[controlMap[0x7]]; -.LINE 168 - - LD HL,_controlMap+7 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+7),A -; 169 -; 170 keys[0x8] = keypad[controlMap[0x8]]; -.LINE 170 - - LD HL,_controlMap+8 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+8),A -; 171 keys[0x9] = keypad[controlMap[0x9]]; -.LINE 171 - - LD HL,_controlMap+9 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+9),A -; 172 keys[0xA] = keypad[controlMap[0xA]]; -.LINE 172 - - LD HL,_controlMap+10 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+10),A -; 173 keys[0xB] = keypad[controlMap[0xB]]; -.LINE 173 - - LD HL,_controlMap+11 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+11),A -; 174 -; 175 keys[0xC] = keypad[controlMap[0xC]]; -.LINE 175 - - LD HL,_controlMap+12 - LD A,(HL) + LD A,(IX+-1) UEXT HL LD L,A + LD BC,_controlMap ADD HL,BC LD A,(HL) - LD (IY+12),A -; 176 keys[0xD] = keypad[controlMap[0xD]]; -.LINE 176 - - LD HL,_controlMap+13 - LD A,(HL) UEXT HL LD L,A + LD BC,_keypad ADD HL,BC - LD A,(HL) - LD (IY+13),A -; 177 keys[0xE] = keypad[controlMap[0xE]]; -.LINE 177 - - LD HL,_controlMap+14 - LD A,(HL) + LD IY,HL + LD A,(IX+-1) UEXT HL LD L,A + LD BC,_keys ADD HL,BC - LD A,(HL) - LD (IY+14),A -; 178 keys[0xF] = keypad[controlMap[0xF]]; -.LINE 178 + LD A,(IY) + LD (HL),A + INC (IX+-1) +; 162 } +L_14: +.LINE 162 - LD HL,_controlMap+15 - LD A,(HL) - UEXT HL - LD L,A - ADD HL,BC - LD A,(HL) - LD (IY+15),A -; 179 -; 180 if(kb_Data[1] & kb_2nd) { -.LINE 180 + LD A,(IX+-1) + CP A,15 + JR C,L_12 +; 163 +; 164 if(kb_Data[1] & kb_2nd) { +.LINE 164 LD A,(16056338) AND A,32 - JR NZ,L_11 - JR L_15 -; 181 while(kb_Data[1] & kb_2nd) { -L_12: -.LINE 181 + JR NZ,L_15 + JR L_20 +; 165 while(kb_Data[1] & kb_2nd) { +L_16: +.LINE 165 -; 182 kb_Scan(); -.LINE 182 +; 166 kb_Scan(); +.LINE 166 CALL _kb_Scan -; 183 } -L_11: -.LINE 183 +; 167 } +L_15: +.LINE 167 LD A,(16056338) AND A,32 - JR NZ,L_12 -; 184 paused = 1; -.LINE 184 + JR NZ,L_16 +; 168 paused = 1; +.LINE 168 LD A,1 LD (_paused),A -; 185 } -; 186 } -L_15: -.LINE 186 +; 169 } +; 170 } +L_20: +.LINE 170 LD SP,IX POP IX @@ -1606,15 +1492,16 @@ L_15: ;_keys STATIC 16 variable ;_controlMap STATIC 16 variable ;_keypad STATIC 16 variable +;i IX-1 1 variable -; Stack Frame Size: 6 (bytes) +; Stack Frame Size: 7 (bytes) ; Spill Code: 0 (instruction) -.ENDFUNC "setKeys",186,"_setKeys" -; 187 -; 188 void emulateCycle(uint8_t steps) { +.ENDFUNC "setKeys",170,"_setKeys" +; 171 +; 172 void emulateCycle(uint8_t steps) { _emulateCycle: .DEFINE "_emulateCycle" @@ -1626,9 +1513,9 @@ _emulateCycle: .ENDEF -.BEGFUNC "emulateCycle",188,"_emulateCycle" +.BEGFUNC "emulateCycle",172,"_emulateCycle" -.LINE 188 +.LINE 172 .DEFINE "steps" @@ -1710,21 +1597,11 @@ _emulateCycle: .ENDEF -.DEFINE "disp" - -.CLASS 65 - -.VALUE -16 - -.TYPE 44 - -.ENDEF - -.DEFINE "xd" +.DEFINE "yd" .CLASS 65 -.VALUE -17 +.VALUE -14 .TYPE 12 @@ -1734,13 +1611,13 @@ _emulateCycle: .CLASS 65 -.VALUE -18 +.VALUE -15 .TYPE 12 .ENDEF -.DEFINE "yd" +.DEFINE "xd" .CLASS 65 @@ -1763,30 +1640,30 @@ _emulateCycle: PUSH IX LD IX,0 ADD IX,SP - LEA HL,IX+-74 + LEA HL,IX+-80 LD SP,HL -; 189 -; 190 kb_Scan(); -.LINE 190 +; 173 +; 174 kb_Scan(); +.LINE 174 CALL _kb_Scan -; 191 setKeys(); -.LINE 191 +; 175 setKeys(); +.LINE 175 CALL _setKeys -; 192 -; 193 for(step = 0; step < steps; ++step) { -.LINE 193 +; 176 +; 177 for(step = 0; step < steps; ++step) { +.LINE 177 XOR A,A LD (_step),A - JR L_170 -L_168: -; 194 int i; -; 195 uint8_t x; -; 196 uint8_t y; -; 197 opcode = (memory[pc] << 8) | memory[pc+1]; -.LINE 197 + JR L_163 +L_161: +; 178 int i; +; 179 uint8_t x; +; 180 uint8_t y; +; 181 opcode = (memory[pc] << 8) | memory[pc+1]; +.LINE 181 LD BC,(_pc) CALL __stoiu @@ -1812,8 +1689,8 @@ L_168: LD (HL),C INC HL LD (HL),B -; 198 x = (opcode & 0x0f00) >> 8; -.LINE 198 +; 182 x = (opcode & 0x0f00) >> 8; +.LINE 182 LD HL,(_opcode) LD A,8 @@ -1823,8 +1700,8 @@ L_168: LD A,L AND A,15 LD (IX+-4),A -; 199 y = (opcode & 0x00f0) >> 4; -.LINE 199 +; 183 y = (opcode & 0x00f0) >> 4; +.LINE 183 LD HL,(_opcode) LD A,4 @@ -1834,9 +1711,9 @@ L_168: LD A,L AND A,15 LD (IX+-5),A -; 200 -; 201 pc += 2; -.LINE 201 +; 184 +; 185 pc += 2; +.LINE 185 LD BC,(_pc) INC BC @@ -1845,9 +1722,9 @@ L_168: LD (HL),C INC HL LD (HL),B -; 202 -; 203 switch(opcode & 0xf000) { -.LINE 203 +; 186 +; 187 switch(opcode & 0xf000) { +.LINE 187 LD BC,(_opcode) CALL __stoiu @@ -1855,64 +1732,64 @@ L_168: CALL __iand CALL __case16D JP (HL) -L__9: +L__10: DW 16 DW 0 - DW24 L_16 + DW24 L_21 DW 4096 - DW24 L_55 + DW24 L_48 DW 8192 - DW24 L_56 + DW24 L_49 DW 12288 - DW24 L_58 + DW24 L_51 DW 16384 - DW24 L_61 + DW24 L_54 DW 20480 - DW24 L_64 + DW24 L_57 DW 24576 - DW24 L_67 + DW24 L_60 DW 28672 - DW24 L_68 + DW24 L_61 DW 32768 - DW24 L_69 + DW24 L_62 DW 36864 - DW24 L_80 + DW24 L_73 DW 40960 - DW24 L_83 + DW24 L_76 DW 45056 - DW24 L_84 + DW24 L_77 DW 49152 - DW24 L_85 + DW24 L_78 DW 53248 - DW24 L_86 + DW24 L_79 DW 57344 - DW24 L_118 + DW24 L_111 DW 61440 - DW24 L_126 + DW24 L_119 - DW24 L_169 + DW24 L_162 -; 204 case 0x0000: { -L_16: -.LINE 204 +; 188 case 0x0000: { +L_21: +.LINE 188 -; 205 switch(opcode & 0x00f0) { -.LINE 205 +; 189 switch(opcode & 0x00f0) { +.LINE 189 LD BC,(_opcode) CALL __stoiu @@ -1923,45 +1800,25 @@ L_16: LD BC,192 OR A,A SBC HL,BC - JR NZ,L_53 -; 206 case 0x00c0: { //SCD -.LINE 206 + JR NZ,L_46 +; 190 case 0x00c0: { //SCD +.LINE 190 -; 207 uint8_t n = (opcode & 0x000f); -.LINE 207 +; 191 uint8_t n = (opcode & 0x000f); +.LINE 191 LD A,(_opcode) AND A,15 LD (IX+-20),A -; 208 uint8_t *disp; -; 209 -; 210 if(extendedScreen) { -.LINE 210 +; 192 uint8_t *disp = &canvas_data[2]; +.LINE 192 - LD A,(_extendedScreen) - OR A,A - JR Z,L_19 -; 211 disp = &scanvas_data[2]; -.LINE 211 - - LD BC,_scanvas_data+2 - LD (IX+-16),BC -; 212 } else { -.LINE 212 - - JR L_24 -L_19: -; 213 disp = &canvas_data[2]; -.LINE 213 - - LD BC,_canvas_data+2 - LD (IX+-16),BC -; 214 } -L_24: -.LINE 214 - -; 215 for(i = screen_height-2; i >= 0; i--) { -.LINE 215 + LD IY,_canvas_data + LEA IY,IY+2 + LD (IX+-23),IY +; 193 +; 194 for(i = screen_height-2; i >= 0; i--) { +.LINE 194 LD A,(_screen_height) UEXT HL @@ -1969,11 +1826,14 @@ L_24: DEC HL DEC HL LD (IX+-3),HL - JR L_23 -L_21: -; 216 memcpy(disp + (i+n)*screen_width, disp + i*screen_width, screen_width); -.LINE 216 + JR L_26 +L_24: +; 195 memcpy(disp + (i+n)*screen_width, disp + i*screen_width, screen_width); +.LINE 195 + LD BC,(IX+-23) + LD (IX+-18),BC + LD (IX+-29),BC LD A,(_screen_width) UEXT HL LD L,A @@ -1984,7 +1844,7 @@ L_21: LD BC,HL LD HL,(IX+-3) CALL __imuls - LD BC,(IX+-16) + LD BC,(IX+-29) ADD HL,BC PUSH HL LD A,(IX+-20) @@ -1999,16 +1859,18 @@ L_21: LD BC,HL LD HL,DE CALL __imuls - LD BC,(IX+-16) + LD BC,(IX+-29) ADD HL,BC PUSH HL CALL _memcpy POP BC POP BC POP BC -; 217 memset(disp + i*screen_width, 0, screen_width); -.LINE 217 +; 196 memset(disp + i*screen_width, 0, screen_width); +.LINE 196 + LD BC,(IX+-18) + LD (IX+-23),BC LD A,(_screen_width) UEXT HL LD L,A @@ -2021,7 +1883,7 @@ L_21: LD BC,HL LD HL,(IX+-3) CALL __imuls - LD BC,(IX+-16) + LD BC,(IX+-18) ADD HL,BC PUSH HL CALL _memset @@ -2031,29 +1893,29 @@ L_21: LD BC,(IX+-3) DEC BC LD (IX+-3),BC -; 218 } -L_23: -.LINE 218 +; 197 } +L_26: +.LINE 197 LD HL,(IX+-3) CALL __icmpzero - JP P,L_21 -; 219 -; 220 drawFlag = true; -.LINE 220 + JP P,L_24 +; 198 +; 199 drawFlag = true; +.LINE 199 LD A,1 LD (_drawFlag),A -; 221 -; 222 break; -; 223 } -; 224 break; -; 225 } -L_53: -.LINE 225 - -; 226 switch(opcode & 0x00ff) { -.LINE 226 +; 200 +; 201 break; +; 202 } +; 203 break; +; 204 } +L_46: +.LINE 204 + +; 205 switch(opcode & 0x00ff) { +.LINE 205 LD BC,(_opcode) CALL __stoiu @@ -2065,61 +1927,39 @@ L_53: L__12: DW 7 DB 224 - DW24 L_26 + DW24 L_28 DB 238 - DW24 L_30 + DW24 L_29 DB 251 - DW24 L_31 + DW24 L_30 DB 252 - DW24 L_40 + DW24 L_36 DB 253 - DW24 L_49 + DW24 L_42 DB 254 - DW24 L_50 + DW24 L_43 DB 255 - DW24 L_51 + DW24 L_44 - DW24 L_52 + DW24 L_45 -; 227 case 0x00e0: -L_26: -.LINE 227 - -; 228 if(extendedScreen) -.LINE 228 - - LD A,(_extendedScreen) - OR A,A - JR Z,L_28 -; 229 memset(scanvas_data + 2, 0, 8192); -.LINE 229 - - LD BC,8192 - PUSH BC - LD BC,0 - PUSH BC - LD BC,_scanvas_data+2 - PUSH BC - CALL _memset - POP BC - POP BC - POP BC -; 230 else -.LINE 230 - - JR L_29 +; 206 case 0x00e0: L_28: -; 231 memset(canvas_data + 2, 0, 2048); -.LINE 231 +.LINE 206 - LD BC,2048 - PUSH BC +; 207 memset(canvas_data + 2, 0, pixel_number); +.LINE 207 + + LD A,(_pixel_number) + UEXT HL + LD L,A + PUSH HL LD BC,0 PUSH BC LD BC,_canvas_data+2 @@ -2128,22 +1968,21 @@ L_28: POP BC POP BC POP BC -L_29: -; 232 drawFlag = true; -.LINE 232 +; 208 drawFlag = true; +.LINE 208 LD A,1 LD (_drawFlag),A -; 233 break; -.LINE 233 +; 209 break; +.LINE 209 - JR L_169 -; 234 case 0x00ee: -L_30: -.LINE 234 + JR L_162 +; 210 case 0x00ee: +L_29: +.LINE 210 -; 235 pc = stack[(--sp)&0xf]; -.LINE 235 +; 211 pc = stack[(--sp)&0xf]; +.LINE 211 LD A,(_sp) DEC A @@ -2159,50 +1998,29 @@ L_30: LD (HL),C INC HL LD (HL),B -; 236 break; -.LINE 236 - - JR L_169 -; 237 case 0x00fb: { //SCR -L_31: -.LINE 237 - -; 238 uint8_t *disp; -; 239 -; 240 if(extendedScreen) { -.LINE 240 - - LD A,(_extendedScreen) - OR A,A - JR Z,L_33 -; 241 disp = &scanvas_data[2]; -.LINE 241 +; 212 break; +.LINE 212 - LD BC,_scanvas_data+2 - LD (IX+-10),BC -; 242 } else { -.LINE 242 + JR L_162 +; 213 case 0x00fb: { //SCR +L_30: +.LINE 213 - JR L_38 -L_33: -; 243 disp = &canvas_data[2]; -.LINE 243 +; 214 uint8_t *disp = &canvas_data[2]; +.LINE 214 LD BC,_canvas_data+2 LD (IX+-10),BC -; 244 } -L_38: -.LINE 244 - -; 245 for(i = 0; i < screen_height; i++) { -.LINE 245 +; 215 +; 216 for(i = 0; i < screen_height; i++) { +.LINE 216 LD BC,0 LD (IX+-3),BC - JR L_37 -L_35: -; 246 memmove(disp + 4, disp, screen_width - 4); -.LINE 246 + JR L_34 +L_32: +; 217 memmove(disp + 4, disp, screen_width - 4); +.LINE 217 LD A,(_screen_width) UEXT HL @@ -2219,8 +2037,8 @@ L_35: POP BC POP BC POP BC -; 247 memset(disp, 0, 4); -.LINE 247 +; 218 memset(disp, 0, 4); +.LINE 218 LD BC,4 PUSH BC @@ -2232,8 +2050,8 @@ L_35: POP BC POP BC POP BC -; 248 disp += screen_width; -.LINE 248 +; 219 disp += screen_width; +.LINE 219 LD A,(_screen_width) UEXT HL @@ -2244,9 +2062,9 @@ L_35: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 249 } -L_37: -.LINE 249 +; 220 } +L_34: +.LINE 220 LD A,(_screen_height) UEXT HL @@ -2255,52 +2073,32 @@ L_37: LD HL,(IX+-3) OR A,A SBC HL,BC - JP M,L_35 -; 250 break; -.LINE 250 - - JR L_169 -; 251 } -; 252 case 0x00fc: { //SCL -L_40: -.LINE 252 - -; 253 uint8_t *disp; -; 254 -; 255 if(extendedScreen) { -.LINE 255 - - LD A,(_extendedScreen) - OR A,A - JR Z,L_42 -; 256 disp = &scanvas_data[2]; -.LINE 256 + CALL __setflag + JP M,L_32 +; 221 break; +.LINE 221 - LD BC,_scanvas_data+2 - LD (IX+-13),BC -; 257 } else { -.LINE 257 + JR L_162 +; 222 } +; 223 case 0x00fc: { //SCL +L_36: +.LINE 223 - JR L_47 -L_42: -; 258 disp = &canvas_data[2]; -.LINE 258 +; 224 uint8_t *disp = &canvas_data[2]; +.LINE 224 LD BC,_canvas_data+2 LD (IX+-13),BC -; 259 } -L_47: -.LINE 259 - -; 260 for(i = 0; i < screen_height; i++) { -.LINE 260 +; 225 +; 226 for(i = 0; i < screen_height; i++) { +.LINE 226 LD BC,0 LD (IX+-3),BC - JR L_46 -L_44: -; 261 memmove(disp, disp + 4, screen_width - 4); -.LINE 261 + JR L_40 +L_38: +; 227 memmove(disp, disp + 4, screen_width - 4); +.LINE 227 LD A,(_screen_width) UEXT HL @@ -2317,8 +2115,8 @@ L_44: POP BC POP BC POP BC -; 262 memset(disp + screen_width - 4, 0, 4); -.LINE 262 +; 228 memset(disp + screen_width - 4, 0, 4); +.LINE 228 LD BC,4 PUSH BC @@ -2336,8 +2134,8 @@ L_44: POP BC POP BC POP BC -; 263 disp += screen_width; -.LINE 263 +; 229 disp += screen_width; +.LINE 229 LD A,(_screen_width) UEXT HL @@ -2348,9 +2146,9 @@ L_44: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 264 } -L_46: -.LINE 264 +; 230 } +L_40: +.LINE 230 LD A,(_screen_height) UEXT HL @@ -2359,124 +2157,111 @@ L_46: LD HL,(IX+-3) OR A,A SBC HL,BC - JP M,L_44 -; 265 break; -.LINE 265 + CALL __setflag + JP M,L_38 +; 231 break; +.LINE 231 - JR L_169 -; 266 } -; 267 case 0x00fd: -L_49: -.LINE 267 + JR L_162 +; 232 } +; 233 case 0x00fd: +L_42: +.LINE 233 -; 268 playing = 0; -.LINE 268 +; 234 playing = 0; +.LINE 234 XOR A,A LD (_playing),A -; 269 //exit -; 270 break; -.LINE 270 +; 235 //exit +; 236 break; +.LINE 236 - JR L_169 -; 271 case 0x00fe: -L_50: -.LINE 271 + JR L_162 +; 237 case 0x00fe: +L_43: +.LINE 237 -; 272 extendedScreen = 0; -.LINE 272 +; 238 extendedScreen = 0; +.LINE 238 XOR A,A LD (_extendedScreen),A -; 273 screen_width = 64; -.LINE 273 +; 239 screen_width = 64; +.LINE 239 LD A,64 LD (_screen_width),A -; 274 screen_height = 32; -.LINE 274 +; 240 screen_height = 32; +.LINE 240 LD A,32 LD (_screen_height),A -; 275 memcpy(canvas_data + 2, scanvas_data + 2, 2048); -.LINE 275 +; 241 canvas_data[0] = 64; +.LINE 241 - LD BC,2048 - PUSH BC - LD BC,_scanvas_data+2 - PUSH BC - LD BC,_canvas_data+2 - PUSH BC - CALL _memcpy - POP BC - POP BC - POP BC -; 276 dbg_sprintf(dbgout, "Extended mode off\n"); -.LINE 276 + LD A,64 + LD (_canvas_data),A +; 242 canvas_data[1] = 32; +.LINE 242 - LD BC,L__18 - PUSH BC - LD BC,16449536 - PUSH BC - CALL _sprintf - POP BC - POP BC -; 277 break; -.LINE 277 + LD HL,_canvas_data + INC HL + LD (HL),32 +; 243 pixel_number = 2048; +.LINE 243 - JR L_169 -; 278 case 0x00ff: -L_51: -.LINE 278 + XOR A,A + LD (_pixel_number),A +; 244 break; +.LINE 244 -; 279 extendedScreen = 1; -.LINE 279 + JR L_162 +; 245 case 0x00ff: +L_44: +.LINE 245 + +; 246 extendedScreen = 1; +.LINE 246 LD A,1 LD (_extendedScreen),A -; 280 screen_width = 128; -.LINE 280 +; 247 screen_width = 128; +.LINE 247 LD A,128 LD (_screen_width),A -; 281 screen_height = 64; -.LINE 281 +; 248 screen_height = 64; +.LINE 248 LD A,64 LD (_screen_height),A -; 282 memcpy(scanvas_data + 2, canvas_data + 2, 2048); -.LINE 282 +; 249 canvas_data[0] = 128; +.LINE 249 - LD BC,2048 - PUSH BC - LD BC,_canvas_data+2 - PUSH BC - LD BC,_scanvas_data+2 - PUSH BC - CALL _memcpy - POP BC - POP BC - POP BC -; 283 dbg_sprintf(dbgout, "Extended mode on\n"); -.LINE 283 + LD A,128 + LD (_canvas_data),A +; 250 canvas_data[1] = 64; +.LINE 250 - LD BC,L__19 - PUSH BC - LD BC,16449536 - PUSH BC - CALL _sprintf - POP BC - POP BC -; 284 break; -.LINE 284 + LD HL,_canvas_data + INC HL + LD (HL),64 +; 251 pixel_number = 8192; +.LINE 251 - JR L_169 -; 285 default: -L_52: -.LINE 285 + XOR A,A + LD (_pixel_number),A +; 252 break; +.LINE 252 -; 286 pc = (pc & 0x0fff); -.LINE 286 + JR L_162 +; 253 default: +L_45: +.LINE 253 + +; 254 pc = (pc & 0x0fff); +.LINE 254 LD HL,(_pc) LD.LIS BC,4095 @@ -2486,19 +2271,19 @@ L_52: LD (HL),C INC HL LD (HL),B -; 287 break; -.LINE 287 +; 255 break; +.LINE 255 - JR L_169 -; 288 } -; 289 break; -; 290 } -; 291 case 0x1000: { -L_55: -.LINE 291 + JR L_162 +; 256 } +; 257 break; +; 258 } +; 259 case 0x1000: { +L_48: +.LINE 259 -; 292 pc = (opcode & 0x0fff); -.LINE 292 +; 260 pc = (opcode & 0x0fff); +.LINE 260 LD HL,(_opcode) LD.LIS BC,4095 @@ -2508,17 +2293,17 @@ L_55: LD (HL),C INC HL LD (HL),B -; 293 break; -.LINE 293 +; 261 break; +.LINE 261 - JR L_169 -; 294 } -; 295 case 0x2000: { -L_56: -.LINE 295 + JR L_162 +; 262 } +; 263 case 0x2000: { +L_49: +.LINE 263 -; 296 stack[sp++] = pc; -.LINE 296 +; 264 stack[sp++] = pc; +.LINE 264 LD A,(_sp) UEXT HL @@ -2534,8 +2319,8 @@ L_56: LD A,(_sp) INC A LD (_sp),A -; 297 pc = (opcode & 0x0fff); -.LINE 297 +; 265 pc = (opcode & 0x0fff); +.LINE 265 LD HL,(_opcode) LD.LIS BC,4095 @@ -2545,17 +2330,17 @@ L_56: LD (HL),C INC HL LD (HL),B -; 298 break; -.LINE 298 +; 266 break; +.LINE 266 - JR L_169 -; 299 } -; 300 case 0x3000: { -L_58: -.LINE 300 + JR L_162 +; 267 } +; 268 case 0x3000: { +L_51: +.LINE 268 -; 301 if(V[x] == (opcode & 0x00ff)) -.LINE 301 +; 269 if(V[x] == (opcode & 0x00ff)) +.LINE 269 LD A,(IX+-4) UEXT HL @@ -2574,9 +2359,9 @@ L_58: LD HL,DE OR A,A SBC HL,BC - JR NZ,L_169 -; 302 pc += 2; -.LINE 302 + JR NZ,L_162 +; 270 pc += 2; +.LINE 270 LD BC,(_pc) INC BC @@ -2585,17 +2370,17 @@ L_58: LD (HL),C INC HL LD (HL),B -; 303 break; -.LINE 303 +; 271 break; +.LINE 271 - JR L_169 -; 304 } -; 305 case 0x4000: { -L_61: -.LINE 305 + JR L_162 +; 272 } +; 273 case 0x4000: { +L_54: +.LINE 273 -; 306 if(V[x] != (opcode & 0x00ff)) -.LINE 306 +; 274 if(V[x] != (opcode & 0x00ff)) +.LINE 274 LD A,(IX+-4) UEXT HL @@ -2614,9 +2399,9 @@ L_61: LD HL,DE OR A,A SBC HL,BC - JR Z,L_169 -; 307 pc += 2; -.LINE 307 + JR Z,L_162 +; 275 pc += 2; +.LINE 275 LD BC,(_pc) INC BC @@ -2625,17 +2410,17 @@ L_61: LD (HL),C INC HL LD (HL),B -; 308 break; -.LINE 308 +; 276 break; +.LINE 276 - JR L_169 -; 309 } -; 310 case 0x5000: { -L_64: -.LINE 310 + JR L_162 +; 277 } +; 278 case 0x5000: { +L_57: +.LINE 278 -; 311 if(V[x] == V[y]) -.LINE 311 +; 279 if(V[x] == V[y]) +.LINE 279 LD A,(IX+-4) UEXT HL @@ -2649,9 +2434,9 @@ L_64: ADD HL,BC LD A,(IY) CP A,(HL) - JR NZ,L_169 -; 312 pc += 2; -.LINE 312 + JR NZ,L_162 +; 280 pc += 2; +.LINE 280 LD BC,(_pc) INC BC @@ -2660,17 +2445,17 @@ L_64: LD (HL),C INC HL LD (HL),B -; 313 break; -.LINE 313 +; 281 break; +.LINE 281 - JR L_169 -; 314 } -; 315 case 0x6000: { -L_67: -.LINE 315 + JR L_162 +; 282 } +; 283 case 0x6000: { +L_60: +.LINE 283 -; 316 V[x] = (opcode & 0x00ff); -.LINE 316 +; 284 V[x] = (opcode & 0x00ff); +.LINE 284 LD A,(_opcode) LD B,A @@ -2680,40 +2465,40 @@ L_67: LD DE,_V ADD HL,DE LD (HL),B -; 317 break; -.LINE 317 +; 285 break; +.LINE 285 - JR L_169 -; 318 } -; 319 case 0x7000: { -L_68: -.LINE 319 + JR L_162 +; 286 } +; 287 case 0x7000: { +L_61: +.LINE 287 -; 320 V[x] = (V[x] + (opcode & 0x00ff)) & 0xff; -.LINE 320 +; 288 V[x] = (V[x] + (opcode & 0x00ff)) & 0xff; +.LINE 288 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-26),HL + LD (IX+-32),HL LD A,(_opcode) - LD HL,(IX+-26) + LD HL,(IX+-32) ADD A,(HL) - LD HL,(IX+-26) + LD HL,(IX+-32) LD (HL),A -; 321 break; -.LINE 321 +; 289 break; +.LINE 289 - JR L_169 -; 322 } -; 323 case 0x8000: { -L_69: -.LINE 323 + JR L_162 +; 290 } +; 291 case 0x8000: { +L_62: +.LINE 291 -; 324 switch(opcode & 0x000f) { -.LINE 324 +; 292 switch(opcode & 0x000f) { +.LINE 292 LD BC,(_opcode) CALL __stoiu @@ -2723,43 +2508,43 @@ L_69: LD L,A CALL __case8D JP (HL) -L__23: +L__18: DW 9 DB 0 - DW24 L_70 + DW24 L_63 DB 1 - DW24 L_71 + DW24 L_64 DB 2 - DW24 L_72 + DW24 L_65 DB 3 - DW24 L_73 + DW24 L_66 DB 4 - DW24 L_74 + DW24 L_67 DB 5 - DW24 L_75 + DW24 L_68 DB 6 - DW24 L_76 + DW24 L_69 DB 7 - DW24 L_77 + DW24 L_70 DB 14 - DW24 L_78 + DW24 L_71 - DW24 L_169 + DW24 L_162 -; 325 case 0x0000: { -L_70: -.LINE 325 +; 293 case 0x0000: { +L_63: +.LINE 293 -; 326 V[x] = V[y]; -.LINE 326 +; 294 V[x] = V[y]; +.LINE 294 LD A,(IX+-5) UEXT HL @@ -2773,105 +2558,105 @@ L_70: ADD HL,BC LD A,(IY) LD (HL),A -; 327 break; -.LINE 327 +; 295 break; +.LINE 295 - JR L_169 -; 328 } -; 329 case 0x0001: { -L_71: -.LINE 329 + JR L_162 +; 296 } +; 297 case 0x0001: { +L_64: +.LINE 297 -; 330 V[x] |= V[y]; -.LINE 330 +; 298 V[x] |= V[y]; +.LINE 298 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-29),HL + LD (IX+-35),HL LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-29) + LD IY,(IX+-35) LD A,(HL) OR A,(IY) - LD HL,(IX+-29) + LD HL,(IX+-35) LD (HL),A -; 331 break; -.LINE 331 +; 299 break; +.LINE 299 - JR L_169 -; 332 } -; 333 case 0x0002: { -L_72: -.LINE 333 + JR L_162 +; 300 } +; 301 case 0x0002: { +L_65: +.LINE 301 -; 334 V[x] &= V[y]; -.LINE 334 +; 302 V[x] &= V[y]; +.LINE 302 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-32),HL + LD (IX+-38),HL LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-32) + LD IY,(IX+-38) LD A,(HL) AND A,(IY) - LD HL,(IX+-32) + LD HL,(IX+-38) LD (HL),A -; 335 break; -.LINE 335 +; 303 break; +.LINE 303 - JR L_169 -; 336 } -; 337 case 0x0003: { -L_73: -.LINE 337 + JR L_162 +; 304 } +; 305 case 0x0003: { +L_66: +.LINE 305 -; 338 V[x] ^= V[y]; -.LINE 338 +; 306 V[x] ^= V[y]; +.LINE 306 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-35),HL + LD (IX+-41),HL LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-35) + LD IY,(IX+-41) LD A,(HL) XOR A,(IY) - LD HL,(IX+-35) + LD HL,(IX+-41) LD (HL),A -; 339 break; -.LINE 339 +; 307 break; +.LINE 307 - JR L_169 -; 340 } -; 341 case 0x0004: { -L_74: -.LINE 341 + JR L_162 +; 308 } +; 309 case 0x0004: { +L_67: +.LINE 309 -; 342 V[0xf] = (V[x] + V[y] > 0xff); -.LINE 342 +; 310 V[0xf] = (V[x] + V[y] > 0xff); +.LINE 310 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-38),HL + LD (IX+-44),HL LD A,(IX+-5) UEXT HL LD L,A @@ -2880,7 +2665,7 @@ L_74: UEXT HL LD L,A LD BC,HL - LD HL,(IX+-38) + LD HL,(IX+-44) LD A,(HL) UEXT HL LD L,A @@ -2890,187 +2675,187 @@ L_74: OR A,A SBC HL,BC CALL __setflag - JP P,L__25 + JP P,L__20 LD A,1 - JR L__26 -L__25: + JR L__21 +L__20: XOR A,A -L__26: +L__21: LD HL,_V+15 LD (HL),A -; 343 V[x] += V[y]; -.LINE 343 +; 311 V[x] += V[y]; +.LINE 311 LD A,(IX+-5) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD IY,(IX+-38) - LD (IX+-62),HL ; spill - LD HL,(IX+-38) - LD (IX+-71),HL ; spill - LD HL,(IX+-62) ; unspill + LD IY,(IX+-44) + LD (IX+-68),HL ; spill + LD HL,(IX+-44) + LD (IX+-77),HL ; spill + LD HL,(IX+-68) ; unspill LD A,(HL) ADD A,(IY) - LD HL,(IX+-71) ; unspill + LD HL,(IX+-77) ; unspill LD (HL),A -; 344 V[x] &= 255; -.LINE 344 +; 312 V[x] &= 255; +.LINE 312 - LD HL,(IX+-38) + LD HL,(IX+-44) LD A,(HL) - LD HL,(IX+-38) + LD HL,(IX+-44) LD (HL),A -; 345 break; -.LINE 345 +; 313 break; +.LINE 313 - JR L_169 -; 346 } -; 347 case 0x0005: { -L_75: -.LINE 347 + JR L_162 +; 314 } +; 315 case 0x0005: { +L_68: +.LINE 315 -; 348 V[0xf] = V[x] >= V[y]; -.LINE 348 +; 316 V[0xf] = V[x] >= V[y]; +.LINE 316 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-41),HL + LD (IX+-47),HL LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-41) + LD IY,(IX+-47) LD A,(IY) CP A,(HL) - JR C,L__28 + JR C,L__23 LD A,1 - JR L__29 -L__28: + JR L__24 +L__23: XOR A,A -L__29: +L__24: LD HL,_V+15 LD (HL),A -; 349 V[x] -= V[y]; -.LINE 349 +; 317 V[x] -= V[y]; +.LINE 317 - LD IY,(IX+-41) + LD IY,(IX+-47) LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD (IX+-62),HL ; spill - LD HL,(IX+-41) LD (IX+-68),HL ; spill - LD HL,(IX+-62) ; unspill + LD HL,(IX+-47) + LD (IX+-74),HL ; spill + LD HL,(IX+-68) ; unspill LD A,(IY) SUB A,(HL) - LD HL,(IX+-68) ; unspill + LD HL,(IX+-74) ; unspill LD (HL),A -; 350 break; -.LINE 350 +; 318 break; +.LINE 318 - JR L_169 -; 351 } -; 352 case 0x0006: { -L_76: -.LINE 352 + JR L_162 +; 319 } +; 320 case 0x0006: { +L_69: +.LINE 320 -; 353 V[0xf] = V[x] & 1; -.LINE 353 +; 321 V[0xf] = V[x] & 1; +.LINE 321 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-44),HL + LD (IX+-50),HL LD A,(HL) AND A,1 LD HL,_V+15 LD (HL),A -; 354 V[x] >>= 1; -.LINE 354 +; 322 V[x] >>= 1; +.LINE 322 - LD HL,(IX+-44) + LD HL,(IX+-50) LD A,(HL) UEXT HL LD L,A LD A,1 CALL __ishrs_b - LD IY,(IX+-44) + LD IY,(IX+-50) LD (IY),L -; 355 break; -.LINE 355 +; 323 break; +.LINE 323 - JR L_169 -; 356 } -; 357 case 0x0007: { -L_77: -.LINE 357 + JR L_162 +; 324 } +; 325 case 0x0007: { +L_70: +.LINE 325 -; 358 V[0xf] = V[y] >= V[x]; -.LINE 358 +; 326 V[0xf] = V[y] >= V[x]; +.LINE 326 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-47),HL + LD (IX+-53),HL LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-47) + LD IY,(IX+-53) LD A,(HL) CP A,(IY) - JR C,L__31 + JR C,L__26 LD A,1 - JR L__32 -L__31: + JR L__27 +L__26: XOR A,A -L__32: +L__27: LD HL,_V+15 LD (HL),A -; 359 V[x] = V[y] - V[x]; -.LINE 359 +; 327 V[x] = V[y] - V[x]; +.LINE 327 LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC - LD IY,(IX+-47) - LD (IX+-62),HL ; spill - LD HL,(IX+-47) - LD (IX+-65),HL ; spill - LD HL,(IX+-62) ; unspill + LD IY,(IX+-53) + LD (IX+-68),HL ; spill + LD HL,(IX+-53) + LD (IX+-71),HL ; spill + LD HL,(IX+-68) ; unspill LD A,(HL) SUB A,(IY) - LD HL,(IX+-65) ; unspill + LD HL,(IX+-71) ; unspill LD (HL),A -; 360 break; -.LINE 360 +; 328 break; +.LINE 328 - JR L_169 -; 361 } -; 362 case 0x000E: { -L_78: -.LINE 362 + JR L_162 +; 329 } +; 330 case 0x000E: { +L_71: +.LINE 330 -; 363 V[0xf] = V[x] >> 7; -.LINE 363 +; 331 V[0xf] = V[x] >> 7; +.LINE 331 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-50),HL + LD (IX+-56),HL LD A,(HL) UEXT HL LD L,A @@ -3078,29 +2863,29 @@ L_78: CALL __ishrs_b LD IY,_V LD (IY+15),L -; 364 V[x] <<= 1; -.LINE 364 +; 332 V[x] <<= 1; +.LINE 332 - LD HL,(IX+-50) + LD HL,(IX+-56) LD A,(HL) ADD A,A - LD HL,(IX+-50) + LD HL,(IX+-56) LD (HL),A -; 365 break; -.LINE 365 +; 333 break; +.LINE 333 - JR L_169 -; 366 } -; 367 break; -; 368 } -; 369 break; -; 370 } -; 371 case 0x9000: { -L_80: -.LINE 371 + JR L_162 +; 334 } +; 335 break; +; 336 } +; 337 break; +; 338 } +; 339 case 0x9000: { +L_73: +.LINE 339 -; 372 if(V[x] != V[y]) -.LINE 372 +; 340 if(V[x] != V[y]) +.LINE 340 LD A,(IX+-4) UEXT HL @@ -3114,9 +2899,9 @@ L_80: ADD HL,BC LD A,(IY) CP A,(HL) - JR Z,L_169 -; 373 pc += 2; -.LINE 373 + JR Z,L_162 +; 341 pc += 2; +.LINE 341 LD BC,(_pc) INC BC @@ -3125,17 +2910,17 @@ L_80: LD (HL),C INC HL LD (HL),B -; 374 break; -.LINE 374 +; 342 break; +.LINE 342 - JR L_169 -; 375 } -; 376 case 0xa000: { -L_83: -.LINE 376 + JR L_162 +; 343 } +; 344 case 0xa000: { +L_76: +.LINE 344 -; 377 I = (opcode & 0x0fff); -.LINE 377 +; 345 I = (opcode & 0x0fff); +.LINE 345 LD HL,(_opcode) LD.LIS BC,4095 @@ -3145,17 +2930,17 @@ L_83: LD (HL),C INC HL LD (HL),B -; 378 break; -.LINE 378 +; 346 break; +.LINE 346 - JR L_169 -; 379 } -; 380 case 0xb000: { -L_84: -.LINE 380 + JR L_162 +; 347 } +; 348 case 0xb000: { +L_77: +.LINE 348 -; 381 pc = V[0] + (opcode & 0x0fff); -.LINE 381 +; 349 pc = V[0] + (opcode & 0x0fff); +.LINE 349 LD A,(_V) LD C,A @@ -3172,23 +2957,23 @@ L_84: LD (HL),C INC HL LD (HL),B -; 382 break; -.LINE 382 +; 350 break; +.LINE 350 - JR L_169 -; 383 } -; 384 case 0xc000: { -L_85: -.LINE 384 + JR L_162 +; 351 } +; 352 case 0xc000: { +L_78: +.LINE 352 -; 385 V[x] = (rand() & 0xff) & (opcode & 0x00FF); -.LINE 385 +; 353 V[x] = (rand() & 0xff) & (opcode & 0x00FF); +.LINE 353 LD A,(_opcode) LD B,A - LD (IX+-74),BC + LD (IX+-80),BC CALL _rand - LD BC,(IX+-74) + LD BC,(IX+-80) LD A,B AND A,L LD B,A @@ -3198,17 +2983,17 @@ L_85: LD DE,_V ADD HL,DE LD (HL),B -; 386 break; -.LINE 386 +; 354 break; +.LINE 354 - JR L_169 -; 387 } -; 388 case 0xd000: { -L_86: -.LINE 388 + JR L_162 +; 355 } +; 356 case 0xd000: { +L_79: +.LINE 356 -; 389 uint8_t xd = V[x]; -.LINE 389 +; 357 uint8_t xd = V[x]; +.LINE 357 LD A,(IX+-4) UEXT HL @@ -3216,67 +3001,67 @@ L_86: LD BC,_V ADD HL,BC LD A,(HL) - LD (IX+-17),A -; 390 uint8_t yd = V[y]; -.LINE 390 + LD (IX+-19),A +; 358 uint8_t yd = V[y]; +.LINE 358 LD A,(IX+-5) UEXT HL LD L,A ADD HL,BC LD A,(HL) - LD (IX+-19),A -; 391 uint8_t height = (opcode & 0x000f); -.LINE 391 + LD (IX+-14),A +; 359 uint8_t height = (opcode & 0x000f); +.LINE 359 LD A,(_opcode) AND A,15 LD (IX+-6),A -; 392 -; 393 V[0xf] = 0; -.LINE 393 +; 360 +; 361 V[0xf] = 0; +.LINE 361 LD HL,_V+15 LD (HL),0 -; 394 -; 395 if(extendedScreen) { -.LINE 395 +; 362 +; 363 if(extendedScreen) { +.LINE 363 LD A,(_extendedScreen) OR A,A - JR Z,L_116 -; 396 //Extended screen DXY0 -; 397 uint8_t cols = 1; -.LINE 397 + JR Z,L_109 +; 364 //Extended screen DXY0 +; 365 uint8_t cols = 1; +.LINE 365 LD (IX+-7),1 -; 398 if(height == 0) { -.LINE 398 +; 366 if(height == 0) { +.LINE 366 LD A,(IX+-6) OR A,A - JR NZ,L_103 -; 399 cols = 2; -.LINE 399 + JR NZ,L_96 +; 367 cols = 2; +.LINE 367 LD (IX+-7),2 -; 400 height = 16; -.LINE 400 +; 368 height = 16; +.LINE 368 LD (IX+-6),16 -; 401 } -L_103: -.LINE 401 +; 369 } +L_96: +.LINE 369 -; 402 for(_y = 0; _y < height; ++_y) { -.LINE 402 +; 370 for(_y = 0; _y < height; ++_y) { +.LINE 370 XOR A,A LD (__y),A - JR L_102 -L_100: -; 403 pixel = memory[I + (cols*_y)]; -.LINE 403 + JR L_95 +L_93: +; 371 pixel = memory[I + (cols*_y)]; +.LINE 371 LD A,(__y) UEXT HL @@ -3299,14 +3084,14 @@ L_100: LD (HL),C INC HL LD (HL),0 -; 404 if(cols == 2) { -.LINE 404 +; 372 if(cols == 2) { +.LINE 372 LD A,(IX+-7) CP A,2 - JR NZ,L_99 -; 405 pixel <<= 8; -.LINE 405 + JR NZ,L_92 +; 373 pixel <<= 8; +.LINE 373 LD HL,(_pixel) LD H,L @@ -3316,8 +3101,8 @@ L_100: LD (HL),C INC HL LD (HL),B -; 406 pixel |= memory[I + (_y << 1)+1]; -.LINE 406 +; 374 pixel |= memory[I + (_y << 1)+1]; +.LINE 374 LD A,(__y) UEXT HL @@ -3340,48 +3125,48 @@ L_100: LD (HL),C INC HL LD (HL),B -; 407 } -L_99: -.LINE 407 +; 375 } +L_92: +.LINE 375 -; 408 for(_x = 0; _x < (cols << 3); ++_x) { -.LINE 408 +; 376 for(_x = 0; _x < (cols << 3); ++_x) { +.LINE 376 XOR A,A LD (__x),A - JR L_98 -L_96: -; 409 if((pixel & (((cols == 2) ? 0x8000 : 0x80) >> _x)) != 0) { -.LINE 409 + JR L_91 +L_89: +; 377 if((pixel & (((cols == 2) ? 0x8000 : 0x80) >> _x)) != 0) { +.LINE 377 LD A,(IX+-7) CP A,2 - JR NZ,L_91 + JR NZ,L_84 LD BC,32768 - LD (IX+-23),BC - JR L_92 -L_91: + LD (IX+-26),BC + JR L_85 +L_84: LD BC,128 - LD (IX+-23),BC -L_92: + LD (IX+-26),BC +L_85: LD A,(__x) UEXT HL LD L,A LD BC,HL - LD HL,(IX+-23) + LD HL,(IX+-26) CALL __ishrs LD BC,(_pixel) CALL __sand CALL __scmpzero - JR Z,L_97 -; 410 index = (((xd + _x) & 0x7f) + (((yd + _y) & 0x3f) << 7)) + 2; -.LINE 410 + JR Z,L_90 +; 378 index = (((xd + _x) & 0x7f) + (((yd + _y) & 0x3f) << 7)) + 2; +.LINE 378 LD A,(__x) LD C,A LD B,0 LD HL,BC - LD C,(IX+-17) + LD C,(IX+-19) ADD.SIS HL,BC LD A,L RES 7,A @@ -3390,7 +3175,7 @@ L_92: LD A,(__y) LD C,A LD HL,BC - LD C,(IX+-19) + LD C,(IX+-14) ADD.SIS HL,BC LD A,L AND A,63 @@ -3413,62 +3198,62 @@ L_92: LD (HL),C INC HL LD (HL),B -; 411 V[0xf] |= scanvas_data[index] & 1; -.LINE 411 +; 379 V[0xf] |= canvas_data[index] & 1; +.LINE 379 LD IY,_V LEA IY,IY+15 - LD (IX+-53),IY + LD (IX+-59),IY LD BC,(_index) CALL __stoiu - LD BC,_scanvas_data + LD BC,_canvas_data ADD HL,BC LD A,(HL) AND A,1 - LD HL,(IX+-53) + LD HL,(IX+-59) OR A,(HL) - LD HL,(IX+-53) + LD HL,(IX+-59) LD (HL),A -; 412 if (scanvas_data[index]) -.LINE 412 +; 380 if (canvas_data[index]) +.LINE 380 LD BC,(_index) CALL __stoiu - LD BC,_scanvas_data + LD BC,_canvas_data ADD HL,BC LD A,(HL) OR A,A - JR Z,L_94 -; 413 scanvas_data[index] = 0; -.LINE 413 + JR Z,L_87 +; 381 canvas_data[index] = 0; +.LINE 381 LD BC,(_index) CALL __stoiu - LD BC,_scanvas_data + LD BC,_canvas_data ADD HL,BC LD (HL),0 -; 414 else -.LINE 414 +; 382 else +.LINE 382 - JR L_97 -L_94: -; 415 scanvas_data[index] = 1; -.LINE 415 + JR L_90 +L_87: +; 383 canvas_data[index] = 1; +.LINE 383 LD BC,(_index) CALL __stoiu - LD BC,_scanvas_data + LD BC,_canvas_data ADD HL,BC LD (HL),1 -; 416 } -; 417 } -L_97: -.LINE 417 +; 384 } +; 385 } +L_90: +.LINE 385 LD A,(__x) INC A LD (__x),A -L_98: +L_91: LD A,(IX+-7) UEXT HL LD L,A @@ -3481,40 +3266,40 @@ L_98: LD L,A OR A,A SBC HL,BC - JP M,L_96 + JP M,L_89 LD A,(__y) INC A LD (__y),A -; 418 } -L_102: -.LINE 418 +; 386 } +L_95: +.LINE 386 LD A,(__y) CP A,(IX+-6) - JR C,L_100 - JR L_117 -; 419 } else { -L_116: -.LINE 419 + JR C,L_93 + JR L_110 +; 387 } else { +L_109: +.LINE 387 -; 420 //Normal screen DXYN -; 421 if(height == 0) height = 16; -.LINE 421 +; 388 //Normal screen DXYN +; 389 if(height == 0) height = 16; +.LINE 389 LD A,(IX+-6) OR A,A - JR NZ,L_114 + JR NZ,L_107 LD (IX+-6),16 -L_114: -; 422 for(_y = 0; _y < height; ++_y) { -.LINE 422 +L_107: +; 390 for(_y = 0; _y < height; ++_y) { +.LINE 390 XOR A,A LD (__y),A - JR L_113 -L_111: -; 423 pixel = memory[I + _y]; -.LINE 423 + JR L_106 +L_104: +; 391 pixel = memory[I + _y]; +.LINE 391 LD BC,(_I) CALL __stoiu @@ -3530,15 +3315,15 @@ L_111: LD (HL),C INC HL LD (HL),0 -; 424 for(_x = 0; _x < 8; ++_x) { -.LINE 424 +; 392 for(_x = 0; _x < 8; ++_x) { +.LINE 392 XOR A,A LD (__x),A - JR L_110 -L_108: -; 425 if((pixel & (0x80 >> _x)) != 0) { -.LINE 425 + JR L_103 +L_101: +; 393 if((pixel & (0x80 >> _x)) != 0) { +.LINE 393 LD A,(__x) UEXT HL @@ -3549,15 +3334,15 @@ L_108: LD BC,(_pixel) CALL __sand CALL __scmpzero - JR Z,L_109 -; 426 index = (((xd + _x) & 0x3f) + (((yd + _y) & 0x1f) << 6)) + 2; -.LINE 426 + JR Z,L_102 +; 394 index = (((xd + _x) & 0x3f) + (((yd + _y) & 0x1f) << 6)) + 2; +.LINE 394 LD A,(__x) LD C,A LD B,0 LD HL,BC - LD C,(IX+-17) + LD C,(IX+-19) ADD.SIS HL,BC LD A,L AND A,63 @@ -3566,7 +3351,7 @@ L_108: LD A,(__y) LD C,A LD HL,BC - LD C,(IX+-19) + LD C,(IX+-14) ADD.SIS HL,BC LD A,L AND A,31 @@ -3588,24 +3373,24 @@ L_108: LD (HL),C INC HL LD (HL),B -; 427 V[0xf] |= canvas_data[index] & 1; -.LINE 427 +; 395 V[0xf] |= canvas_data[index] & 1; +.LINE 395 LD IY,_V LEA IY,IY+15 - LD (IX+-56),IY + LD (IX+-62),IY LD BC,(_index) CALL __stoiu LD BC,_canvas_data ADD HL,BC LD A,(HL) AND A,1 - LD HL,(IX+-56) + LD HL,(IX+-62) OR A,(HL) - LD HL,(IX+-56) + LD HL,(IX+-62) LD (HL),A -; 428 if (canvas_data[index]) -.LINE 428 +; 396 if (canvas_data[index]) +.LINE 396 LD BC,(_index) CALL __stoiu @@ -3613,72 +3398,72 @@ L_108: ADD HL,BC LD A,(HL) OR A,A - JR Z,L_106 -; 429 canvas_data[index] = 0; -.LINE 429 + JR Z,L_99 +; 397 canvas_data[index] = 0; +.LINE 397 LD BC,(_index) CALL __stoiu LD BC,_canvas_data ADD HL,BC LD (HL),0 -; 430 else -.LINE 430 +; 398 else +.LINE 398 - JR L_109 -L_106: -; 431 canvas_data[index] = 1; -.LINE 431 + JR L_102 +L_99: +; 399 canvas_data[index] = 1; +.LINE 399 LD BC,(_index) CALL __stoiu LD BC,_canvas_data ADD HL,BC LD (HL),1 -; 432 } -; 433 } -L_109: -.LINE 433 +; 400 } +; 401 } +L_102: +.LINE 401 LD A,(__x) INC A LD (__x),A -L_110: +L_103: LD A,(__x) CP A,8 - JR C,L_108 + JR C,L_101 LD A,(__y) INC A LD (__y),A -; 434 } -L_113: -.LINE 434 +; 402 } +L_106: +.LINE 402 LD A,(__y) CP A,(IX+-6) - JR C,L_111 -; 435 } -L_117: -.LINE 435 + JR C,L_104 +; 403 } +L_110: +.LINE 403 -; 436 -; 437 drawFlag = true; -.LINE 437 +; 404 +; 405 drawFlag = true; +.LINE 405 LD A,1 LD (_drawFlag),A -; 438 -; 439 break; -.LINE 439 +; 406 +; 407 break; +.LINE 407 - JR L_169 -; 440 } -; 441 case 0xe000: { -L_118: -.LINE 441 + JR L_162 +; 408 } +; 409 case 0xe000: { +L_111: +.LINE 409 -; 442 switch(opcode & 0x00ff) { -.LINE 442 +; 410 switch(opcode & 0x00ff) { +.LINE 410 LD BC,(_opcode) CALL __stoiu @@ -3687,22 +3472,22 @@ L_118: LD L,A CALL __case8D JP (HL) -L__47: +L__42: DW 2 DB 158 - DW24 L_119 + DW24 L_112 DB 161 - DW24 L_122 + DW24 L_115 - DW24 L_169 + DW24 L_162 -; 443 case 0x009e: { -L_119: -.LINE 443 +; 411 case 0x009e: { +L_112: +.LINE 411 -; 444 if(keys[V[x]]) -.LINE 444 +; 412 if(keys[V[x]]) +.LINE 412 LD A,(IX+-4) UEXT HL @@ -3716,9 +3501,9 @@ L_119: ADD HL,BC LD A,(HL) OR A,A - JR Z,L_169 -; 445 pc += 2; -.LINE 445 + JR Z,L_162 +; 413 pc += 2; +.LINE 413 LD BC,(_pc) INC BC @@ -3727,17 +3512,17 @@ L_119: LD (HL),C INC HL LD (HL),B -; 446 break; -.LINE 446 +; 414 break; +.LINE 414 - JR L_169 -; 447 } -; 448 case 0x00a1: { -L_122: -.LINE 448 + JR L_162 +; 415 } +; 416 case 0x00a1: { +L_115: +.LINE 416 -; 449 if(!keys[V[x]]) -.LINE 449 +; 417 if(!keys[V[x]]) +.LINE 417 LD A,(IX+-4) UEXT HL @@ -3751,9 +3536,9 @@ L_122: ADD HL,BC LD A,(HL) OR A,A - JR NZ,L_169 -; 450 pc += 2; -.LINE 450 + JR NZ,L_162 +; 418 pc += 2; +.LINE 418 LD BC,(_pc) INC BC @@ -3762,20 +3547,20 @@ L_122: LD (HL),C INC HL LD (HL),B -; 451 break; -.LINE 451 +; 419 break; +.LINE 419 - JR L_169 -; 452 } -; 453 } -; 454 break; -; 455 } -; 456 case 0xf000: { -L_126: -.LINE 456 + JR L_162 +; 420 } +; 421 } +; 422 break; +; 423 } +; 424 case 0xf000: { +L_119: +.LINE 424 -; 457 switch(opcode & 0x00ff) { -.LINE 457 +; 425 switch(opcode & 0x00ff) { +.LINE 425 LD BC,(_opcode) CALL __stoiu @@ -3784,52 +3569,52 @@ L_126: LD L,A CALL __case8D JP (HL) -L__50: +L__45: DW 12 DB 7 - DW24 L_127 + DW24 L_120 DB 10 - DW24 L_128 + DW24 L_121 DB 21 - DW24 L_135 + DW24 L_128 DB 24 - DW24 L_137 + DW24 L_130 DB 30 - DW24 L_138 + DW24 L_131 DB 41 - DW24 L_139 + DW24 L_132 DB 48 - DW24 L_140 + DW24 L_133 DB 51 - DW24 L_141 + DW24 L_134 DB 85 - DW24 L_142 + DW24 L_135 DB 101 - DW24 L_147 + DW24 L_140 DB 117 - DW24 L_152 + DW24 L_145 DB 133 - DW24 L_159 + DW24 L_152 - DW24 L_169 + DW24 L_162 -; 458 case 0x0007: { -L_127: -.LINE 458 +; 426 case 0x0007: { +L_120: +.LINE 426 -; 459 V[x] = delay_timer; -.LINE 459 +; 427 V[x] = delay_timer; +.LINE 427 LD A,(_delay_timer) LD B,A @@ -3839,21 +3624,21 @@ L_127: LD DE,_V ADD HL,DE LD (HL),B -; 460 break; -.LINE 460 +; 428 break; +.LINE 428 - JR L_169 -; 461 } -; 462 case 0x000A: { -L_128: -.LINE 462 + JR L_162 +; 429 } +; 430 case 0x000A: { +L_121: +.LINE 430 -; 463 bool key_pressed = false; -.LINE 463 +; 431 bool key_pressed = false; +.LINE 431 - LD (IX+-18),0 -; 464 pc -= 2; -.LINE 464 + LD (IX+-15),0 +; 432 pc -= 2; +.LINE 432 LD IY,(_pc) LEA BC,IY+-2 @@ -3861,25 +3646,25 @@ L_128: LD (HL),C INC HL LD (HL),B -; 465 -; 466 for(i = 0; i < 16; ++i) { -.LINE 466 +; 433 +; 434 for(i = 0; i < 16; ++i) { +.LINE 434 LD BC,0 LD (IX+-3),BC - JR L_132 -L_130: -; 467 if(keys[i]) { -.LINE 467 + JR L_125 +L_123: +; 435 if(keys[i]) { +.LINE 435 LD BC,_keys LD HL,(IX+-3) ADD HL,BC LD A,(HL) OR A,A - JR Z,L_131 -; 468 V[x] = i; -.LINE 468 + JR Z,L_124 +; 436 V[x] = i; +.LINE 436 LD B,(IX+-3) LD A,(IX+-4) @@ -3888,8 +3673,8 @@ L_130: LD DE,_V ADD HL,DE LD (HL),B -; 469 pc += 2; -.LINE 469 +; 437 pc += 2; +.LINE 437 LD BC,(_pc) INC BC @@ -3898,48 +3683,48 @@ L_130: LD (HL),C INC HL LD (HL),B -; 470 key_pressed = true; -.LINE 470 +; 438 key_pressed = true; +.LINE 438 - LD (IX+-18),1 -; 471 break; -.LINE 471 + LD (IX+-15),1 +; 439 break; +.LINE 439 - JR L_134 -; 472 } -; 473 } -L_131: -.LINE 473 + JR L_127 +; 440 } +; 441 } +L_124: +.LINE 441 LD BC,(IX+-3) INC BC LD (IX+-3),BC -L_132: +L_125: LD BC,16 LD HL,(IX+-3) OR A,A SBC HL,BC - JP M,L_130 -L_134: -; 474 -; 475 if(!key_pressed) -.LINE 475 + JP M,L_123 +L_127: +; 442 +; 443 if(!key_pressed) +.LINE 443 - LD A,(IX+-18) + LD A,(IX+-15) OR A,A - JR Z,L_175 -; 476 return; -.LINE 476 + JR Z,L_168 +; 444 return; +.LINE 444 -; 477 } -.LINE 477 +; 445 } +.LINE 445 -; 478 case 0x0015: { -L_135: -.LINE 478 +; 446 case 0x0015: { +L_128: +.LINE 446 -; 479 delay_timer = V[x]; -.LINE 479 +; 447 delay_timer = V[x]; +.LINE 447 LD A,(IX+-4) UEXT HL @@ -3951,17 +3736,17 @@ L_135: LD (HL),C INC HL LD (HL),0 -; 480 break; -.LINE 480 +; 448 break; +.LINE 448 - JR L_169 -; 481 } -; 482 case 0x0018: { -L_137: -.LINE 482 + JR L_162 +; 449 } +; 450 case 0x0018: { +L_130: +.LINE 450 -; 483 sound_timer = V[x]; -.LINE 483 +; 451 sound_timer = V[x]; +.LINE 451 LD A,(IX+-4) UEXT HL @@ -3973,17 +3758,17 @@ L_137: LD (HL),C INC HL LD (HL),0 -; 484 break; -.LINE 484 +; 452 break; +.LINE 452 - JR L_169 -; 485 } -; 486 case 0x001E: { -L_138: -.LINE 486 + JR L_162 +; 453 } +; 454 case 0x001E: { +L_131: +.LINE 454 -; 487 I = (I + V[x]) & 0xffff; -.LINE 487 +; 455 I = (I + V[x]) & 0xffff; +.LINE 455 LD A,(IX+-4) UEXT HL @@ -4000,17 +3785,17 @@ L_138: LD (HL),C INC HL LD (HL),B -; 488 break; -.LINE 488 +; 456 break; +.LINE 456 - JR L_169 -; 489 } -; 490 case 0x0029: { -L_139: -.LINE 490 + JR L_162 +; 457 } +; 458 case 0x0029: { +L_132: +.LINE 458 -; 491 I = (V[x] & 0xf) * 5; -.LINE 491 +; 459 I = (V[x] & 0xf) * 5; +.LINE 459 LD A,(IX+-4) UEXT HL @@ -4028,17 +3813,17 @@ L_139: LD (HL),C INC HL LD (HL),B -; 492 break; -.LINE 492 +; 460 break; +.LINE 460 - JR L_169 -; 493 } -; 494 case 0x0030: { -L_140: -.LINE 494 + JR L_162 +; 461 } +; 462 case 0x0030: { +L_133: +.LINE 462 -; 495 I = (V[x] & 0xf) * 10 + 80; -.LINE 495 +; 463 I = (V[x] & 0xf) * 10 + 80; +.LINE 463 LD A,(IX+-4) UEXT HL @@ -4057,24 +3842,24 @@ L_140: LD (HL),C INC HL LD (HL),B -; 496 break; -.LINE 496 +; 464 break; +.LINE 464 - JR L_169 -; 497 } -; 498 case 0x0033: { -L_141: -.LINE 498 + JR L_162 +; 465 } +; 466 case 0x0033: { +L_134: +.LINE 466 -; 499 memory[ I ] = V[x] / 100; -.LINE 499 +; 467 memory[ I ] = V[x] / 100; +.LINE 467 LD A,(IX+-4) UEXT HL LD L,A LD BC,_V ADD HL,BC - LD (IX+-59),HL + LD (IX+-65),HL LD A,(HL) UEXT HL LD L,A @@ -4086,10 +3871,10 @@ L_141: LD BC,_memory ADD HL,BC LD (HL),A -; 500 memory[I+1] = (V[x] / 10) % 10; -.LINE 500 +; 468 memory[I+1] = (V[x] / 10) % 10; +.LINE 468 - LD HL,(IX+-59) + LD HL,(IX+-65) LD A,(HL) UEXT HL LD L,A @@ -4104,10 +3889,10 @@ L_141: LD BC,_memory ADD HL,BC LD (HL),A -; 501 memory[I+2] = V[x] % 10; -.LINE 501 +; 469 memory[I+2] = V[x] % 10; +.LINE 469 - LD HL,(IX+-59) + LD HL,(IX+-65) LD A,(HL) UEXT HL LD L,A @@ -4121,24 +3906,24 @@ L_141: LD BC,_memory ADD HL,BC LD (HL),A -; 502 break; -.LINE 502 +; 470 break; +.LINE 470 - JR L_169 -; 503 } -; 504 case 0x0055: { -L_142: -.LINE 504 + JR L_162 +; 471 } +; 472 case 0x0055: { +L_135: +.LINE 472 -; 505 for(i = 0; i <= x; ++i) { -.LINE 505 +; 473 for(i = 0; i <= x; ++i) { +.LINE 473 LD BC,0 LD (IX+-3),BC - JR L_145 -L_143: -; 506 memory[I + i] = V[i]; -.LINE 506 + JR L_138 +L_136: +; 474 memory[I + i] = V[i]; +.LINE 474 LD BC,_V LD HL,(IX+-3) @@ -4155,9 +3940,9 @@ L_143: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 507 } -L_145: -.LINE 507 +; 475 } +L_138: +.LINE 475 LD A,(IX+-4) UEXT HL @@ -4165,25 +3950,25 @@ L_145: LD BC,(IX+-3) OR A,A SBC HL,BC - JP P,L_143 -; 508 break; -.LINE 508 + JP P,L_136 +; 476 break; +.LINE 476 - JR L_169 -; 509 } -; 510 case 0x0065: { -L_147: -.LINE 510 + JR L_162 +; 477 } +; 478 case 0x0065: { +L_140: +.LINE 478 -; 511 for(i = 0; i <= x; ++i) { -.LINE 511 +; 479 for(i = 0; i <= x; ++i) { +.LINE 479 LD BC,0 LD (IX+-3),BC - JR L_150 -L_148: -; 512 V[i] = memory[I + i]; -.LINE 512 + JR L_143 +L_141: +; 480 V[i] = memory[I + i]; +.LINE 480 LD BC,(_I) CALL __stoiu @@ -4200,9 +3985,9 @@ L_148: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 513 } -L_150: -.LINE 513 +; 481 } +L_143: +.LINE 481 LD A,(IX+-4) UEXT HL @@ -4211,33 +3996,33 @@ L_150: OR A,A SBC HL,BC CALL __setflag - JP P,L_148 -; 514 break; -.LINE 514 + JP P,L_141 +; 482 break; +.LINE 482 - JR L_169 -; 515 } -; 516 case 0x0075: { -L_152: -.LINE 516 + JR L_162 +; 483 } +; 484 case 0x0075: { +L_145: +.LINE 484 -; 517 if (x > 7) x = 7; -.LINE 517 +; 485 if (x > 7) x = 7; +.LINE 485 LD A,7 CP A,(IX+-4) - JR NC,L_157 + JR NC,L_150 LD (IX+-4),7 -L_157: -; 518 for(i = 0; i <= x; ++i) { -.LINE 518 +L_150: +; 486 for(i = 0; i <= x; ++i) { +.LINE 486 LD BC,0 LD (IX+-3),BC - JR L_156 -L_154: -; 519 SV[i] = V[i]; -.LINE 519 + JR L_149 +L_147: +; 487 SV[i] = V[i]; +.LINE 487 LD BC,_V LD HL,(IX+-3) @@ -4251,9 +4036,9 @@ L_154: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 520 } -L_156: -.LINE 520 +; 488 } +L_149: +.LINE 488 LD A,(IX+-4) UEXT HL @@ -4262,33 +4047,33 @@ L_156: OR A,A SBC HL,BC CALL __setflag - JP P,L_154 -; 521 break; -.LINE 521 + JP P,L_147 +; 489 break; +.LINE 489 - JR L_169 -; 522 } -; 523 case 0x0085: { -L_159: -.LINE 523 + JR L_162 +; 490 } +; 491 case 0x0085: { +L_152: +.LINE 491 -; 524 if (x > 7) x = 7; -.LINE 524 +; 492 if (x > 7) x = 7; +.LINE 492 LD A,7 CP A,(IX+-4) - JR NC,L_164 + JR NC,L_157 LD (IX+-4),7 -L_164: -; 525 for(i = 0; i <= x; ++i) { -.LINE 525 +L_157: +; 493 for(i = 0; i <= x; ++i) { +.LINE 493 LD BC,0 LD (IX+-3),BC - JR L_163 -L_161: -; 526 V[i] = SV[i]; -.LINE 526 + JR L_156 +L_154: +; 494 V[i] = SV[i]; +.LINE 494 LD BC,_SV LD HL,(IX+-3) @@ -4302,9 +4087,9 @@ L_161: LD BC,(IX+-3) INC BC LD (IX+-3),BC -; 527 } -L_163: -.LINE 527 +; 495 } +L_156: +.LINE 495 LD A,(IX+-4) UEXT HL @@ -4313,28 +4098,28 @@ L_163: OR A,A SBC HL,BC CALL __setflag - JP P,L_161 -; 528 break; -; 529 } -; 530 } -; 531 break; -; 532 } -; 533 default: -; 534 break; -; 535 } -; 536 } -L_169: -.LINE 536 + JP P,L_154 +; 496 break; +; 497 } +; 498 } +; 499 break; +; 500 } +; 501 default: +; 502 break; +; 503 } +; 504 } +L_162: +.LINE 504 LD A,(_step) INC A LD (_step),A -L_170: +L_163: LD A,(_step) CP A,(IX+6) - JR C,L_168 -; 537 if(sound_timer > 0) { -.LINE 537 + JR C,L_161 +; 505 if(sound_timer > 0) { +.LINE 505 LD BC,(_sound_timer) OR A,A @@ -4342,9 +4127,9 @@ L_170: OR A,A SBC.SIS HL,BC CALL __setflag - JP P,L_174 -; 538 --sound_timer; -.LINE 538 + JP P,L_167 +; 506 --sound_timer; +.LINE 506 LD BC,(_sound_timer) DEC BC @@ -4352,12 +4137,12 @@ L_170: LD (HL),C INC HL LD (HL),B -; 539 } -L_174: -.LINE 539 +; 507 } +L_167: +.LINE 507 -; 540 if(delay_timer > 0) { -.LINE 540 +; 508 if(delay_timer > 0) { +.LINE 508 LD BC,(_delay_timer) OR A,A @@ -4365,9 +4150,9 @@ L_174: OR A,A SBC.SIS HL,BC CALL __setflag - JP P,L_175 -; 541 --delay_timer; -.LINE 541 + JP P,L_168 +; 509 --delay_timer; +.LINE 509 LD BC,(_delay_timer) DEC BC @@ -4375,10 +4160,10 @@ L_174: LD (HL),C INC HL LD (HL),B -; 542 } -; 543 } -L_175: -.LINE 543 +; 510 } +; 511 } +L_168: +.LINE 511 LD SP,IX POP IX @@ -4398,31 +4183,31 @@ L_175: ;_rand IMPORT ----- function ;_I STATIC 2 variable ;_V STATIC 16 variable -;_sprintf IMPORT ----- function +;_extendedScreen STATIC 1 variable ;_playing STATIC 1 variable ;_memmove IMPORT ----- function ;_stack STATIC 32 variable ;_sp STATIC 1 variable +;_pixel_number STATIC 1 variable ;_drawFlag STATIC 1 variable ;_memset IMPORT ----- function ;_screen_width STATIC 1 variable ;_memcpy IMPORT ----- function ;_screen_height STATIC 1 variable -;_canvas_data IMPORT 2050 variable -;_scanvas_data IMPORT 8194 variable -;_extendedScreen STATIC 1 variable +;_canvas_data STATIC 8194 variable ;_opcode STATIC 2 variable ;_pc STATIC 2 variable ;_memory STATIC 4096 variable ;_step STATIC 1 variable ;_setKeys IMPORT ----- function ;_kb_Scan IMPORT ----- function -;temp89 IX-23 3 variable +;temp82 IX-26 3 variable +;G_0 IX-23 3 variable ;n IX-20 1 variable -;yd IX-19 1 variable -;key_pressed IX-18 1 variable -;xd IX-17 1 variable -;disp IX-16 3 variable +;xd IX-19 1 variable +;G_1 IX-18 3 variable +;key_pressed IX-15 1 variable +;yd IX-14 1 variable ;disp IX-13 3 variable ;disp IX-10 3 variable ;cols IX-7 1 variable @@ -4433,25 +4218,15 @@ L_175: ;steps IX+6 1 parameter -; Stack Frame Size: 83 (bytes) +; Stack Frame Size: 89 (bytes) ; Spill Code: 0 (instruction) -.ENDFUNC "emulateCycle",543,"_emulateCycle" - SEGMENT STRSECT -L__18: - DB "Extended mode off" - DB 10,0 -L__19: - DB "Extended mode on" - DB 10,0 - XREF _scanvas_data:ROM - XREF _canvas_data:ROM +.ENDFUNC "emulateCycle",511,"_emulateCycle" XREF _kb_Scan:ROM XREF _memmove:ROM XREF _memset:ROM XREF _memcpy:ROM - XREF _sprintf:ROM XREF _ti_GetSize:ROM XREF _ti_Read:ROM XREF _ti_Open:ROM @@ -4478,6 +4253,7 @@ L__19: XDEF _setKeys XDEF _loadProgram XDEF _initialize + XDEF _pixel_number XDEF _screen_height XDEF _screen_width XDEF __x @@ -4490,7 +4266,9 @@ L__19: XDEF _file XDEF _controlMap XDEF _keypad + XDEF _canvas_data XDEF _game_data + XDEF _plane XDEF _extendedScreen XDEF _playing XDEF _paused diff --git a/obj/main.src b/obj/main.src index ac0ba4d..2be81ff 100644 --- a/obj/main.src +++ b/obj/main.src @@ -621,94 +621,93 @@ _data: ; 2 #include ; 3 #include ; 4 #include -; 5 #include -; 6 -; 7 #include -; 8 #include -; 9 #include -; 10 #include -; 11 -; 12 #include -; 13 #include -; 14 #include -; 15 -; 16 #include "chip8.h" -; 17 #include "sprites_gfx.h" -; 18 -; 19 void drawGraphics(void); -; 20 void startEmulation(char *fileName); -; 21 void drawMenu(uint8_t start); -; 22 void drawKeymappingMenu(uint8_t selected); -; 23 void beginKeymapper(char *fileName); -; 24 void beginSetClock(void); -; 25 void drawPreview(uint8_t x, uint8_t y); -; 26 -; 27 ti_var_t curFile; -; 28 -; 29 char files[255][9]; -; 30 uint8_t count; -; 31 -; 32 uint8_t bgColor = 0x88; -; 33 uint8_t cpf = 10; -; 34 -; 35 uint8_t frameCount = 0; -; 36 -; 37 uint8_t fgIndex = 1; -; 38 uint8_t bgIndex = 0; -; 39 -; 40 const char *pauseText = "[2nd] - Pause"; -; 41 const char *keyNames[16] = { -; 42 "Decimal", -; 43 "Seven", -; 44 "Eight", -; 45 "Nine", -; 46 "Four", -; 47 "Five", -; 48 "Six", -; 49 "One", -; 50 "Two", -; 51 "Three", -; 52 "Zero", -; 53 "Negative", -; 54 "Times", -; 55 "Plus", -; 56 "Minus", -; 57 "Enter" -; 58 }; -; 59 -; 60 const uint16_t palette_colors[20] = { -; 61 0x0000, // 00 :: rgb(0,0,1) -; 62 0x37BD, // 01 :: rgb(108,234,239) -; 63 0xAC43, // 02 :: rgb(92,21,21) -; 64 0x916C, // 03 :: rgb(30,95,97) -; 65 0x90CE, // 04 :: rgb(35,51,113) -; 66 0xFFFF, // 05 :: rgb(255,255,255) -; 67 0xFFEE, // 06 :: rgb(255,253,113) -; 68 0xB63F, // 07 :: rgb(111,141,253) -; 69 0x0CE3, // 08 :: rgb(25,55,25) -; 70 0xDEF7, // 09 :: rgb(191,191,191) -; 71 0xB5A4, // 10 :: rgb(110,109,34) -; 72 0xFDDF, // 11 :: rgb(255,118,253) -; 73 0x5DFF, // 12 :: rgb(188,122,255) -; 74 0xB06C, // 13 :: rgb(98,28,97) -; 75 0x28E2, // 14 :: rgb(80,58,18) -; 76 0xFF0C, // 15 :: rgb(252,197,102) -; 77 0xA06C, // 16 :: rgb(63,28,99) -; 78 0xE508, // 17 :: rgb(203,68,68) -; 79 0x36AD, // 18 :: rgb(110,172,110) -; 80 0x14A5, // 19 :: rgb(39,39,39) -; 81 }; -; 82 -; 83 ti_var_t settings; -; 84 typedef struct { -; 85 uint8_t fgColor; -; 86 uint8_t bgColor; -; 87 uint8_t cpf; -; 88 } data_t; -; 89 data_t data; +; 5 +; 6 #include +; 7 #include +; 8 #include +; 9 #include +; 10 +; 11 #include +; 12 #include +; 13 #include +; 14 +; 15 #include "chip8.h" +; 16 #include "sprites_gfx.h" +; 17 +; 18 void drawGraphics(void); +; 19 void startEmulation(char *fileName); +; 20 void drawMenu(uint8_t start); +; 21 void drawKeymappingMenu(uint8_t selected); +; 22 void beginKeymapper(char *fileName); +; 23 void beginSetClock(void); +; 24 void drawPreview(uint8_t x, uint8_t y); +; 25 +; 26 ti_var_t curFile; +; 27 +; 28 char files[255][9]; +; 29 uint8_t count; +; 30 +; 31 uint8_t bgColor = 0x88; +; 32 uint8_t cpf = 10; +; 33 +; 34 uint8_t frameCount = 0; +; 35 +; 36 uint8_t fgIndex = 1; +; 37 uint8_t bgIndex = 0; +; 38 +; 39 const char *pauseText = "[2nd] - Pause"; +; 40 const char *keyNames[16] = { +; 41 "Decimal", +; 42 "Seven", +; 43 "Eight", +; 44 "Nine", +; 45 "Four", +; 46 "Five", +; 47 "Six", +; 48 "One", +; 49 "Two", +; 50 "Three", +; 51 "Zero", +; 52 "Negative", +; 53 "Times", +; 54 "Plus", +; 55 "Minus", +; 56 "Enter" +; 57 }; +; 58 +; 59 const uint16_t palette_colors[20] = { +; 60 0x0000, // 00 :: rgb(0,0,1) +; 61 0x37BD, // 01 :: rgb(108,234,239) +; 62 0xAC43, // 02 :: rgb(92,21,21) +; 63 0x916C, // 03 :: rgb(30,95,97) +; 64 0x90CE, // 04 :: rgb(35,51,113) +; 65 0xFFFF, // 05 :: rgb(255,255,255) +; 66 0xFFEE, // 06 :: rgb(255,253,113) +; 67 0xB63F, // 07 :: rgb(111,141,253) +; 68 0x0CE3, // 08 :: rgb(25,55,25) +; 69 0xDEF7, // 09 :: rgb(191,191,191) +; 70 0xB5A4, // 10 :: rgb(110,109,34) +; 71 0xFDDF, // 11 :: rgb(255,118,253) +; 72 0x5DFF, // 12 :: rgb(188,122,255) +; 73 0xB06C, // 13 :: rgb(98,28,97) +; 74 0x28E2, // 14 :: rgb(80,58,18) +; 75 0xFF0C, // 15 :: rgb(252,197,102) +; 76 0xA06C, // 16 :: rgb(63,28,99) +; 77 0xE508, // 17 :: rgb(203,68,68) +; 78 0x36AD, // 18 :: rgb(110,172,110) +; 79 0x14A5, // 19 :: rgb(39,39,39) +; 80 }; +; 81 +; 82 ti_var_t settings; +; 83 typedef struct { +; 84 uint8_t fgColor; +; 85 uint8_t bgColor; +; 86 uint8_t cpf; +; 87 } data_t; +; 88 data_t data; SEGMENT CODE -; 90 -; 91 void main(void) { +; 89 +; 90 void main(void) { _main: .DEFINE "_main" @@ -720,9 +719,9 @@ _main: .ENDEF -.BEGFUNC "main",91,"_main" +.BEGFUNC "main",90,"_main" -.LINE 91 +.LINE 90 .DEFINE "startPos" @@ -771,36 +770,36 @@ _main: ADD IX,SP LEA HL,IX+-29 LD SP,HL -; 92 uint8_t i; -; 93 char *varName; -; 94 uint8_t *search_pos = NULL; -.LINE 94 +; 91 uint8_t i; +; 92 char *varName; +; 93 uint8_t *search_pos = NULL; +.LINE 93 LD BC,0 LD (IX+-7),BC -; 95 uint8_t startPos = 0; -.LINE 95 +; 94 uint8_t startPos = 0; +.LINE 94 LD (IX+-1),0 -; 96 uint8_t test1[16] = {0x00,0x01,0x02,0x03,0x06,0x05,0x04,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; -.LINE 96 +; 95 uint8_t test1[16] = {0x00,0x01,0x02,0x03,0x06,0x05,0x04,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; +.LINE 95 LEA DE,IX+-23 LD HL,_0temp0 LD BC,16 LDIR -; 97 -; 98 boot_Set48MHzMode(); -.LINE 98 +; 96 +; 97 boot_Set48MHzMode(); +.LINE 97 CALL _boot_Set48MHzMode -; 99 -; 100 ti_CloseAll(); -.LINE 100 +; 98 +; 99 ti_CloseAll(); +.LINE 99 CALL _ti_CloseAll -; 101 settings = ti_Open("C84SET", "r"); -.LINE 101 +; 100 settings = ti_Open("C84SET", "r"); +.LINE 100 LD BC,L__17 PUSH BC @@ -810,63 +809,43 @@ _main: POP BC POP BC LD (_settings),A -; 102 dbg_sprintf(dbgout, "%d", ti_GetSize(settings)); -.LINE 102 - - LD C,A - LD B,0 - PUSH BC - CALL _ti_GetSize - POP BC - LD BC,HL - CALL __stoiu - PUSH HL - LD BC,L__19 - PUSH BC - LD BC,16449536 - PUSH BC - CALL _sprintf - POP BC - POP BC - POP BC -; 103 if(settings == 0) { -.LINE 103 +; 101 if(settings == 0) { +.LINE 101 - LD A,(_settings) OR A,A JR NZ,L_2 -; 104 ti_CloseAll(); -.LINE 104 +; 102 ti_CloseAll(); +.LINE 102 CALL _ti_CloseAll -; 105 settings = ti_Open("C84SET", "w"); -.LINE 105 +; 103 settings = ti_Open("C84SET", "w"); +.LINE 103 - LD BC,L__21 + LD BC,L__20 PUSH BC - LD BC,L__22 + LD BC,L__21 PUSH BC CALL _ti_Open POP BC POP BC LD (_settings),A -; 106 data.fgColor = 0x1; -.LINE 106 +; 104 data.fgColor = 0x1; +.LINE 104 LD A,1 LD (_data),A -; 107 data.bgColor = 0x0; -.LINE 107 +; 105 data.bgColor = 0x0; +.LINE 105 XOR A,A LD (_data+1),A -; 108 data.cpf = 20; -.LINE 108 +; 106 data.cpf = 20; +.LINE 106 LD A,20 LD (_data+2),A -; 109 ti_Write(&data, sizeof(data_t), 1, settings); -.LINE 109 +; 107 ti_Write(&data, sizeof(data_t), 1, settings); +.LINE 107 LD A,(_settings) LD C,A @@ -883,8 +862,8 @@ _main: POP BC POP BC POP BC -; 110 ti_Rewind(settings); -.LINE 110 +; 108 ti_Rewind(settings); +.LINE 108 LD A,(_settings) LD C,A @@ -892,12 +871,12 @@ _main: PUSH BC CALL _ti_Rewind POP BC -; 111 } +; 109 } L_2: -.LINE 111 +.LINE 109 -; 112 ti_Read(&data, sizeof(data_t), 1, settings); -.LINE 112 +; 110 ti_Read(&data, sizeof(data_t), 1, settings); +.LINE 110 LD A,(_settings) LD C,A @@ -914,23 +893,23 @@ L_2: POP BC POP BC POP BC -; 113 fgIndex = data.fgColor; -.LINE 113 +; 111 fgIndex = data.fgColor; +.LINE 111 LD A,(_data) LD (_fgIndex),A -; 114 bgIndex = data.bgColor; -.LINE 114 +; 112 bgIndex = data.bgColor; +.LINE 112 LD A,(_data+1) LD (_bgIndex),A -; 115 cpf = data.cpf; -.LINE 115 +; 113 cpf = data.cpf; +.LINE 113 LD A,(_data+2) LD (_cpf),A -; 116 sprites_gfx_pal[0] = palette_colors[bgIndex]; -.LINE 116 +; 114 sprites_gfx_pal[0] = palette_colors[bgIndex]; +.LINE 114 LD A,(_bgIndex) UEXT HL @@ -943,8 +922,8 @@ L_2: LD (HL),C INC HL LD (HL),B -; 117 sprites_gfx_pal[1] = palette_colors[fgIndex]; -.LINE 117 +; 115 sprites_gfx_pal[1] = palette_colors[fgIndex]; +.LINE 115 LD A,(_fgIndex) UEXT HL @@ -961,40 +940,40 @@ L_2: LD (HL),C INC HL LD (HL),B -; 118 -; 119 count = 0; -.LINE 119 +; 116 +; 117 count = 0; +.LINE 117 XOR A,A LD (_count),A -; 120 -; 121 gfx_Begin(gfx_8bpp); -.LINE 121 +; 118 +; 119 gfx_Begin(gfx_8bpp); +.LINE 119 LD BC,39 PUSH BC CALL _gfx_Begin POP BC -; 122 gfx_Blit(gfx_screen); -.LINE 122 +; 120 gfx_Blit(gfx_screen); +.LINE 120 LD BC,0 PUSH BC CALL _gfx_Blit POP BC -; 123 gfx_SetDrawBuffer(); -.LINE 123 +; 121 gfx_SetDrawBuffer(); +.LINE 121 LD BC,1 PUSH BC CALL _gfx_SetDraw POP BC -; 124 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); -.LINE 124 +; 122 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); +.LINE 122 LD BC,0 PUSH BC - LD BC,12 + LD BC,4 PUSH BC LD BC,_sprites_gfx_pal PUSH BC @@ -1002,23 +981,23 @@ L_2: POP BC POP BC POP BC -; 125 gfx_SetColor(0x03); -.LINE 125 +; 123 gfx_SetColor(0x03); +.LINE 123 LD BC,3 PUSH BC CALL _gfx_SetColor POP BC -; 126 -; 127 gfx_SetTextFGColor(0x02); -.LINE 127 +; 124 +; 125 gfx_SetTextFGColor(0x02); +.LINE 125 LD BC,2 PUSH BC CALL _gfx_SetTextFGColor POP BC -; 128 gfx_SetTextScale(2, 2); -.LINE 128 +; 126 gfx_SetTextScale(2, 2); +.LINE 126 LD BC,2 PUSH BC @@ -1026,21 +1005,21 @@ L_2: CALL _gfx_SetTextScale POP BC POP BC -; 129 gfx_PrintStringXY("Chip-84", 103, 95); -.LINE 129 +; 127 gfx_PrintStringXY("Chip-84", 103, 95); +.LINE 127 LD BC,95 PUSH BC LD BC,103 PUSH BC - LD BC,L__23 + LD BC,L__22 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 130 gfx_SetTextScale(1, 1); -.LINE 130 +; 128 gfx_SetTextScale(1, 1); +.LINE 128 LD BC,1 PUSH BC @@ -1048,55 +1027,55 @@ L_2: CALL _gfx_SetTextScale POP BC POP BC -; 131 gfx_PrintStringXY("2018 Christian Kosman", 80, 120); -.LINE 131 +; 129 gfx_PrintStringXY("2018 Christian Kosman", 80, 120); +.LINE 129 LD BC,120 PUSH BC LD BC,80 PUSH BC - LD BC,L__24 + LD BC,L__23 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 132 gfx_PrintStringXY("version 2.3.0", LCD_WIDTH-100, LCD_HEIGHT-30); -.LINE 132 +; 130 gfx_PrintStringXY("version 2.3.1", LCD_WIDTH-100, LCD_HEIGHT-30); +.LINE 130 LD BC,210 PUSH BC LD BC,220 PUSH BC - LD BC,L__25 + LD BC,L__24 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 133 gfx_BlitBuffer(); -.LINE 133 +; 131 gfx_BlitBuffer(); +.LINE 131 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 134 -; 135 delay(1000); -.LINE 135 +; 132 +; 133 delay(1000); +.LINE 133 LD BC,1000 PUSH BC CALL _delay POP BC -; 136 -; 137 while((varName = ti_Detect(&search_pos, "Chip84")) != NULL) { -.LINE 137 +; 134 +; 135 while((varName = ti_Detect(&search_pos, "Chip84")) != NULL) { +.LINE 135 JR L_3 L_4: -; 138 strcpy(files[count], varName); -.LINE 138 +; 136 strcpy(files[count], varName); +.LINE 136 LD BC,(IX+-4) PUSH BC @@ -1111,17 +1090,17 @@ L_4: CALL _strcpy POP BC POP BC -; 139 ++count; -.LINE 139 +; 137 ++count; +.LINE 137 LD A,(_count) INC A LD (_count),A -; 140 } +; 138 } L_3: -.LINE 140 +.LINE 138 - LD BC,L__26 + LD BC,L__25 PUSH BC PEA IX+-7 CALL _ti_Detect @@ -1130,80 +1109,80 @@ L_3: LD (IX+-4),HL CALL __icmpzero JR NZ,L_4 -; 141 -; 142 drawMenu(0); -.LINE 142 +; 139 +; 140 drawMenu(0); +.LINE 140 LD BC,0 PUSH BC CALL _drawMenu POP BC -; 143 -; 144 do { +; 141 +; 142 do { L_27: -.LINE 144 +.LINE 142 -; 145 kb_Scan(); -.LINE 145 +; 143 kb_Scan(); +.LINE 143 CALL _kb_Scan -; 146 -; 147 if(kb_Data[7] & kb_Up) { -.LINE 147 +; 144 +; 145 if(kb_Data[7] & kb_Up) { +.LINE 145 LD A,(16056350) AND A,8 JR Z,L_18 -; 148 frameCount = 0; -.LINE 148 +; 146 frameCount = 0; +.LINE 146 XOR A,A LD (_frameCount),A -; 149 if(startPos == 0) -.LINE 149 +; 147 if(startPos == 0) +.LINE 147 LD A,(IX+-1) OR A,A JR NZ,L_8 -; 150 startPos = count-1; -.LINE 150 +; 148 startPos = count-1; +.LINE 148 LD A,(_count) DEC A LD (IX+-1),A -; 151 else -.LINE 151 +; 149 else +.LINE 149 JR L_9 L_8: -; 152 startPos--; -.LINE 152 +; 150 startPos--; +.LINE 150 DEC (IX+-1) L_9: -; 153 drawMenu(startPos); -.LINE 153 +; 151 drawMenu(startPos); +.LINE 151 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawMenu POP BC -; 154 } else if(kb_Data[7] & kb_Down) { -.LINE 154 +; 152 } else if(kb_Data[7] & kb_Down) { +.LINE 152 JR L_25 L_18: LD A,(16056350) AND A,1 JR Z,L_16 -; 155 frameCount = 0; -.LINE 155 +; 153 frameCount = 0; +.LINE 153 XOR A,A LD (_frameCount),A -; 156 if(startPos == count-1) -.LINE 156 +; 154 if(startPos == count-1) +.LINE 154 LD A,(_count) UEXT HL @@ -1218,45 +1197,45 @@ L_18: OR A,A SBC HL,DE JR NZ,L_12 -; 157 startPos = 0; -.LINE 157 +; 155 startPos = 0; +.LINE 155 LD (IX+-1),0 -; 158 else -.LINE 158 +; 156 else +.LINE 156 JR L_13 L_12: -; 159 startPos++; -.LINE 159 +; 157 startPos++; +.LINE 157 INC (IX+-1) L_13: -; 160 drawMenu(startPos); -.LINE 160 +; 158 drawMenu(startPos); +.LINE 158 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawMenu POP BC -; 161 } else if(kb_Data[6] & kb_Enter) { -.LINE 161 +; 159 } else if(kb_Data[6] & kb_Enter) { +.LINE 159 JR L_25 L_16: LD A,(16056348) AND A,1 JR Z,L_25 -; 162 gfx_FillScreen(0xFF); -.LINE 162 +; 160 gfx_FillScreen(0xFF); +.LINE 160 LD BC,255 PUSH BC CALL _gfx_FillScreen POP BC -; 163 startEmulation(files[startPos]); -.LINE 163 +; 161 startEmulation(files[startPos]); +.LINE 161 LD A,(IX+-1) UEXT HL @@ -1268,39 +1247,39 @@ L_16: PUSH HL CALL _startEmulation POP BC -; 164 drawMenu(startPos); -.LINE 164 +; 162 drawMenu(startPos); +.LINE 162 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawMenu POP BC -; 165 } +; 163 } L_25: -.LINE 165 +.LINE 163 -; 166 -; 167 if(frameCount > 9) { -.LINE 167 +; 164 +; 165 if(frameCount > 9) { +.LINE 165 LD A,9 LD HL,_frameCount CP A,(HL) JR NC,L_24 -; 168 if(frameCount < 100) { -.LINE 168 +; 166 if(frameCount < 100) { +.LINE 166 LD A,(_frameCount) CP A,100 JR NC,L_20 -; 169 frameCount = 101; -.LINE 169 +; 167 frameCount = 101; +.LINE 167 LD A,101 LD (_frameCount),A -; 170 loadProgram(files[startPos]); -.LINE 170 +; 168 loadProgram(files[startPos]); +.LINE 168 LD A,(IX+-1) UEXT HL @@ -1312,39 +1291,39 @@ L_25: PUSH HL CALL _loadProgram POP BC -; 171 gfx_PrintStringXY("Preview", 187, 60); -.LINE 171 +; 169 gfx_PrintStringXY("Preview", 187, 60); +.LINE 169 LD BC,60 PUSH BC LD BC,187 PUSH BC - LD BC,L__35 + LD BC,L__34 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 172 } +; 170 } L_20: -.LINE 172 +.LINE 170 -; 173 emulateCycle(20); -.LINE 173 +; 171 emulateCycle(20); +.LINE 171 LD BC,20 PUSH BC CALL _emulateCycle POP BC -; 174 -; 175 if(drawFlag) -.LINE 175 +; 172 +; 173 if(drawFlag) +.LINE 173 LD A,(_drawFlag) OR A,A JR Z,L_26 -; 176 drawPreview(150, 70); -.LINE 176 +; 174 drawPreview(150, 70); +.LINE 174 LD BC,70 PUSH BC @@ -1353,49 +1332,49 @@ L_20: CALL _drawPreview POP BC POP BC -; 177 } else { -.LINE 177 +; 175 } else { +.LINE 175 JR L_26 L_24: -; 178 frameCount++; -.LINE 178 +; 176 frameCount++; +.LINE 176 LD A,(_frameCount) INC A LD (_frameCount),A -; 179 delay(100); -.LINE 179 +; 177 delay(100); +.LINE 177 LD BC,100 PUSH BC CALL _delay POP BC -; 180 } +; 178 } L_26: -.LINE 180 +.LINE 178 -; 181 -; 182 gfx_BlitBuffer(); -.LINE 182 +; 179 +; 180 gfx_BlitBuffer(); +.LINE 180 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 183 } while (kb_Data[6] != kb_Clear); -.LINE 183 +; 181 } while (kb_Data[6] != kb_Clear); +.LINE 181 LD A,(16056348) CP A,64 JR NZ,L_27 -; 184 -; 185 gfx_End(); -.LINE 185 +; 182 +; 183 gfx_End(); +.LINE 183 CALL _gfx_End -; 186 } -.LINE 186 +; 184 } +.LINE 184 LD SP,IX POP IX @@ -1427,7 +1406,7 @@ L_26: ;_gfx_Blit IMPORT ----- function ;_gfx_Begin IMPORT ----- function ;_count STATIC 1 variable -;_sprites_gfx_pal IMPORT 12 variable +;_sprites_gfx_pal IMPORT 8 variable ;_palette_colors STATIC 40 variable ;_cpf STATIC 1 variable ;_bgIndex STATIC 1 variable @@ -1436,8 +1415,6 @@ L_26: ;_ti_Rewind IMPORT ----- function ;_ti_Write IMPORT ----- function ;_data STATIC 3 variable -;_ti_GetSize IMPORT ----- function -;_sprintf IMPORT ----- function ;_settings STATIC 1 variable ;_ti_Open IMPORT ----- function ;_ti_CloseAll IMPORT ----- function @@ -1453,7 +1430,7 @@ L_26: ; Spill Code: 0 (instruction) -.ENDFUNC "main",186,"_main" +.ENDFUNC "main",184,"_main" SEGMENT STRSECT L__17: DB "r" @@ -1461,28 +1438,25 @@ L__17: L__18: DB "C84SET" DB 0 -L__19: - DB "%d" +L__20: + DB "w" DB 0 L__21: - DB "w" + DB "C84SET" DB 0 L__22: - DB "C84SET" + DB "Chip-84" DB 0 L__23: - DB "Chip-84" + DB "2018 Christian Kosman" DB 0 L__24: - DB "2018 Christian Kosman" + DB "version 2.3.1" DB 0 L__25: - DB "version 2.3.0" - DB 0 -L__26: DB "Chip84" DB 0 -L__35: +L__34: DB "Preview" DB 0 SEGMENT TEXT @@ -1504,8 +1478,8 @@ _0temp0: DB 14 DB 15 SEGMENT CODE -; 187 -; 188 void drawMenu(uint8_t start) { +; 185 +; 186 void drawMenu(uint8_t start) { _drawMenu: .DEFINE "_drawMenu" @@ -1517,9 +1491,9 @@ _drawMenu: .ENDEF -.BEGFUNC "drawMenu",188,"_drawMenu" +.BEGFUNC "drawMenu",186,"_drawMenu" -.LINE 188 +.LINE 186 .DEFINE "start" @@ -1545,29 +1519,29 @@ _drawMenu: LD IX,0 ADD IX,SP DEC SP -; 189 uint8_t i; -; 190 gfx_FillScreen(0xff); -.LINE 190 +; 187 uint8_t i; +; 188 gfx_FillScreen(0xff); +.LINE 188 LD BC,255 PUSH BC CALL _gfx_FillScreen POP BC -; 191 gfx_SetTextFGColor(0x02); -.LINE 191 +; 189 gfx_SetTextFGColor(0x02); +.LINE 189 LD BC,2 PUSH BC CALL _gfx_SetTextFGColor POP BC -; 192 for(i = 0; i < 16; i++) { -.LINE 192 +; 190 for(i = 0; i < 16; i++) { +.LINE 190 LD (IX+-1),0 JR L_35 L_33: -; 193 if(i + start <= count-1) { -.LINE 193 +; 191 if(i + start <= count-1) { +.LINE 191 LD A,(_count) UEXT HL @@ -1587,8 +1561,8 @@ L_33: OR A,A SBC HL,DE JP M,L_34 -; 194 gfx_PrintStringXY(files[i+start], 30, 10*i+50); -.LINE 194 +; 192 gfx_PrintStringXY(files[i+start], 30, 10*i+50); +.LINE 192 LD A,(IX+-1) UEXT HL @@ -1617,32 +1591,32 @@ L_33: POP BC POP BC POP BC -; 195 } -; 196 } +; 193 } +; 194 } L_34: -.LINE 196 +.LINE 194 INC (IX+-1) L_35: LD A,(IX+-1) CP A,16 JR C,L_33 -; 197 gfx_PrintStringXY(">",20,50); -.LINE 197 +; 195 gfx_PrintStringXY(">",20,50); +.LINE 195 LD BC,50 PUSH BC LD BC,20 PUSH BC - LD BC,L__41 + LD BC,L__40 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 198 -; 199 gfx_SetTextScale(2,2); -.LINE 199 +; 196 +; 197 gfx_SetTextScale(2,2); +.LINE 197 LD BC,2 PUSH BC @@ -1650,20 +1624,20 @@ L_35: CALL _gfx_SetTextScale POP BC POP BC -; 200 gfx_PrintStringXY("Select a ROM", 20, 20); -.LINE 200 +; 198 gfx_PrintStringXY("Select a ROM", 20, 20); +.LINE 198 LD BC,20 PUSH BC PUSH BC - LD BC,L__42 + LD BC,L__41 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 201 gfx_SetTextScale(1,1); -.LINE 201 +; 199 gfx_SetTextScale(1,1); +.LINE 199 LD BC,1 PUSH BC @@ -1671,21 +1645,21 @@ L_35: CALL _gfx_SetTextScale POP BC POP BC -; 202 gfx_PrintStringXY("[clear] - Quit", 220, 220); -.LINE 202 +; 200 gfx_PrintStringXY("[clear] - Quit", 220, 220); +.LINE 200 LD BC,220 PUSH BC PUSH BC - LD BC,L__43 + LD BC,L__42 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 203 -; 204 } -.LINE 204 +; 201 +; 202 } +.LINE 202 LD SP,IX POP IX @@ -1708,20 +1682,20 @@ L_35: ; Spill Code: 0 (instruction) -.ENDFUNC "drawMenu",204,"_drawMenu" +.ENDFUNC "drawMenu",202,"_drawMenu" SEGMENT STRSECT -L__41: +L__40: DB ">" DB 0 -L__42: +L__41: DB "Select a ROM" DB 0 -L__43: +L__42: DB "[clear] - Quit" DB 0 SEGMENT CODE -; 205 -; 206 void startEmulation(char *fileName) { +; 203 +; 204 void startEmulation(char *fileName) { _startEmulation: .DEFINE "_startEmulation" @@ -1733,9 +1707,9 @@ _startEmulation: .ENDEF -.BEGFUNC "startEmulation",206,"_startEmulation" +.BEGFUNC "startEmulation",204,"_startEmulation" -.LINE 206 +.LINE 204 .DEFINE "fileName" @@ -1763,17 +1737,17 @@ _startEmulation: PUSH BC PUSH BC DEC SP -; 207 -; 208 loadProgram(fileName); -.LINE 208 +; 205 +; 206 loadProgram(fileName); +.LINE 206 LD BC,(IX+6) PUSH BC CALL _loadProgram POP BC -; 209 -; 210 gfx_FillScreen(bgColor); -.LINE 210 +; 207 +; 208 gfx_FillScreen(bgColor); +.LINE 208 LD A,(_bgColor) LD C,A @@ -1781,15 +1755,15 @@ _startEmulation: PUSH BC CALL _gfx_FillScreen POP BC -; 211 gfx_SetTextFGColor(0x03); -.LINE 211 +; 209 gfx_SetTextFGColor(254); +.LINE 209 - LD BC,3 + LD BC,254 PUSH BC CALL _gfx_SetTextFGColor POP BC -; 212 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); -.LINE 212 +; 210 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); +.LINE 210 LD BC,220 PUSH BC @@ -1801,13 +1775,13 @@ _startEmulation: POP BC POP BC POP BC -; 213 -; 214 do { +; 211 +; 212 do { L_99: -.LINE 214 +.LINE 212 -; 215 emulateCycle(cpf); -.LINE 215 +; 213 emulateCycle(cpf); +.LINE 213 LD A,(_cpf) LD C,A @@ -1815,39 +1789,39 @@ L_99: PUSH BC CALL _emulateCycle POP BC -; 216 -; 217 if(drawFlag) -.LINE 217 +; 214 +; 215 if(drawFlag) +.LINE 215 LD A,(_drawFlag) OR A,A JR Z,L_39 -; 218 drawGraphics(); -.LINE 218 +; 216 drawGraphics(); +.LINE 216 CALL _drawGraphics L_39: -; 219 -; 220 gfx_BlitBuffer(); -.LINE 220 +; 217 +; 218 gfx_BlitBuffer(); +.LINE 218 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 221 if(paused) { -.LINE 221 +; 219 if(paused) { +.LINE 219 LD A,(_paused) OR A,A JR Z,L_100 -; 222 uint8_t selected_option = 0; -.LINE 222 +; 220 uint8_t selected_option = 0; +.LINE 220 LD (IX+-1),0 -; 223 -; 224 gfx_FillScreen(bgColor); -.LINE 224 +; 221 +; 222 gfx_FillScreen(bgColor); +.LINE 222 LD A,(_bgColor) LD C,A @@ -1855,8 +1829,8 @@ L_39: PUSH BC CALL _gfx_FillScreen POP BC -; 225 drawPreview(170,135); -.LINE 225 +; 223 drawPreview(170,135); +.LINE 223 LD BC,135 PUSH BC @@ -1865,8 +1839,8 @@ L_39: CALL _drawPreview POP BC POP BC -; 226 gfx_SetTextScale(2, 2); -.LINE 226 +; 224 gfx_SetTextScale(2, 2); +.LINE 224 LD BC,2 PUSH BC @@ -1874,20 +1848,20 @@ L_39: CALL _gfx_SetTextScale POP BC POP BC -; 227 gfx_PrintStringXY("Paused", 20, 20); -.LINE 227 +; 225 gfx_PrintStringXY("Paused", 20, 20); +.LINE 225 LD BC,20 PUSH BC PUSH BC - LD BC,L__47 + LD BC,L__46 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 228 gfx_SetTextScale(1, 1); -.LINE 228 +; 226 gfx_SetTextScale(1, 1); +.LINE 226 LD BC,1 PUSH BC @@ -1895,93 +1869,93 @@ L_39: CALL _gfx_SetTextScale POP BC POP BC -; 229 gfx_PrintStringXY("Keymapping", 20, 50); -.LINE 229 +; 227 gfx_PrintStringXY("Keymapping", 20, 50); +.LINE 227 LD BC,50 PUSH BC LD BC,20 PUSH BC - LD BC,L__48 + LD BC,L__47 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 230 gfx_PrintStringXY("Cycles per frame -", 20, 60); -.LINE 230 +; 228 gfx_PrintStringXY("Cycles per frame -", 20, 60); +.LINE 228 LD BC,60 PUSH BC LD BC,20 PUSH BC - LD BC,L__49 + LD BC,L__48 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 231 gfx_PrintStringXY("Foreground color -", 20, 70); -.LINE 231 +; 229 gfx_PrintStringXY("Foreground color -", 20, 70); +.LINE 229 LD BC,70 PUSH BC LD BC,20 PUSH BC - LD BC,L__50 + LD BC,L__49 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 232 gfx_PrintStringXY("Background color -", 20, 80); -.LINE 232 +; 230 gfx_PrintStringXY("Background color -", 20, 80); +.LINE 230 LD BC,80 PUSH BC LD BC,20 PUSH BC - LD BC,L__51 + LD BC,L__50 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 233 gfx_PrintStringXY("Resume", 20, 90); -.LINE 233 +; 231 gfx_PrintStringXY("Resume", 20, 90); +.LINE 231 LD BC,90 PUSH BC LD BC,20 PUSH BC - LD BC,L__52 + LD BC,L__51 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 234 gfx_PrintStringXY("Quit game", 20, 100); -.LINE 234 +; 232 gfx_PrintStringXY("Quit game", 20, 100); +.LINE 232 LD BC,100 PUSH BC LD BC,20 PUSH BC - LD BC,L__53 + LD BC,L__52 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 235 gfx_BlitBuffer(); -.LINE 235 +; 233 gfx_BlitBuffer(); +.LINE 233 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 236 gfx_SetColor(bgColor); -.LINE 236 +; 234 gfx_SetColor(bgColor); +.LINE 234 LD A,(_bgColor) LD C,A @@ -1989,18 +1963,18 @@ L_39: PUSH BC CALL _gfx_SetColor POP BC -; 237 while(paused) { -.LINE 237 +; 235 while(paused) { +.LINE 235 JR L_96 L_97: -; 238 kb_Scan(); -.LINE 238 +; 236 kb_Scan(); +.LINE 236 CALL _kb_Scan -; 239 -; 240 gfx_FillRectangle(10, 50 + selected_option*10, 10, 10); -.LINE 240 +; 237 +; 238 gfx_FillRectangle(10, 50 + selected_option*10, 10, 10); +.LINE 238 LD BC,10 PUSH BC @@ -2020,52 +1994,52 @@ L_97: POP BC POP BC POP BC -; 241 -; 242 if(kb_Data[7] & kb_Up) { -.LINE 242 +; 239 +; 240 if(kb_Data[7] & kb_Up) { +.LINE 240 LD A,(16056350) AND A,8 JR Z,L_46 -; 243 selected_option--; -.LINE 243 +; 241 selected_option--; +.LINE 241 DEC (IX+-1) -; 244 if(selected_option == 255) selected_option = 5; -.LINE 244 +; 242 if(selected_option == 255) selected_option = 5; +.LINE 242 LD A,(IX+-1) CP A,255 JR NZ,L_46 LD (IX+-1),5 -; 245 } +; 243 } L_46: -.LINE 245 +.LINE 243 -; 246 if(kb_Data[7] & kb_Down) { -.LINE 246 +; 244 if(kb_Data[7] & kb_Down) { +.LINE 244 LD A,(16056350) AND A,1 JR Z,L_47 -; 247 selected_option++; -.LINE 247 +; 245 selected_option++; +.LINE 245 INC (IX+-1) -; 248 if(selected_option == 6) selected_option = 0; -.LINE 248 +; 246 if(selected_option == 6) selected_option = 0; +.LINE 246 LD A,(IX+-1) CP A,6 JR NZ,L_47 LD (IX+-1),0 -; 249 } +; 247 } L_47: -.LINE 249 +.LINE 247 -; 250 -; 251 gfx_PrintStringXY(">", 10, 50 + selected_option*10); -.LINE 251 +; 248 +; 249 gfx_PrintStringXY(">", 10, 50 + selected_option*10); +.LINE 249 LD A,(IX+-1) UEXT HL @@ -2077,34 +2051,34 @@ L_47: PUSH BC LD BC,10 PUSH BC - LD BC,L__58 + LD BC,L__57 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 252 -; 253 if(selected_option == 0) { -.LINE 253 +; 250 +; 251 if(selected_option == 0) { +.LINE 251 LD A,(IX+-1) OR A,A JR NZ,L_58 -; 254 if(kb_Data[6] & kb_Enter) { -.LINE 254 +; 252 if(kb_Data[6] & kb_Enter) { +.LINE 252 LD A,(16056348) AND A,1 JR Z,L_58 -; 255 beginKeymapper(fileName); -.LINE 255 +; 253 beginKeymapper(fileName); +.LINE 253 LD BC,(IX+6) PUSH BC CALL _beginKeymapper POP BC -; 256 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); -.LINE 256 +; 254 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); +.LINE 254 LD BC,220 PUSH BC @@ -2116,67 +2090,67 @@ L_47: POP BC POP BC POP BC -; 257 } -; 258 } +; 255 } +; 256 } L_58: -.LINE 258 +.LINE 256 -; 259 -; 260 if(selected_option == 1) { -.LINE 260 +; 257 +; 258 if(selected_option == 1) { +.LINE 258 LD A,(IX+-1) CP A,1 JR NZ,L_59 -; 261 if(kb_Data[7] & kb_Left) { -.LINE 261 +; 259 if(kb_Data[7] & kb_Left) { +.LINE 259 LD A,(16056350) AND A,2 JR Z,L_56 -; 262 cpf--; -.LINE 262 +; 260 cpf--; +.LINE 260 LD A,(_cpf) DEC A LD (_cpf),A -; 263 if(cpf == 0) cpf = 50; -.LINE 263 +; 261 if(cpf == 0) cpf = 50; +.LINE 261 OR A,A JR NZ,L_56 LD A,50 LD (_cpf),A -; 264 } +; 262 } L_56: -.LINE 264 +.LINE 262 -; 265 if(kb_Data[7] & kb_Right) { -.LINE 265 +; 263 if(kb_Data[7] & kb_Right) { +.LINE 263 LD A,(16056350) AND A,4 JR Z,L_59 -; 266 cpf++; -.LINE 266 +; 264 cpf++; +.LINE 264 LD A,(_cpf) INC A LD (_cpf),A -; 267 if(cpf == 51) cpf = 1; -.LINE 267 +; 265 if(cpf == 51) cpf = 1; +.LINE 265 CP A,51 JR NZ,L_59 LD A,1 LD (_cpf),A -; 268 } -; 269 } +; 266 } +; 267 } L_59: -.LINE 269 +.LINE 267 -; 270 gfx_FillRectangle(150, 60, 30, 30); -.LINE 270 +; 268 gfx_FillRectangle(150, 60, 30, 30); +.LINE 268 LD BC,30 PUSH BC @@ -2190,8 +2164,8 @@ L_59: POP BC POP BC POP BC -; 271 gfx_SetTextXY(150, 60); -.LINE 271 +; 269 gfx_SetTextXY(150, 60); +.LINE 269 LD BC,60 PUSH BC @@ -2200,8 +2174,8 @@ L_59: CALL _gfx_SetTextXY POP BC POP BC -; 272 gfx_PrintUInt(cpf, 2); -.LINE 272 +; 270 gfx_PrintUInt(cpf, 2); +.LINE 270 LD BC,2 PUSH BC @@ -2212,61 +2186,61 @@ L_59: CALL _gfx_PrintUInt POP BC POP BC -; 273 -; 274 if(selected_option == 2) { -.LINE 274 +; 271 +; 272 if(selected_option == 2) { +.LINE 272 LD A,(IX+-1) CP A,2 JR NZ,L_69 -; 275 if(kb_Data[7] & kb_Left) { -.LINE 275 +; 273 if(kb_Data[7] & kb_Left) { +.LINE 273 LD A,(16056350) AND A,2 JR Z,L_66 -; 276 fgIndex--; -.LINE 276 +; 274 fgIndex--; +.LINE 274 LD A,(_fgIndex) DEC A LD (_fgIndex),A -; 277 if(fgIndex == 255) fgIndex = 19; -.LINE 277 +; 275 if(fgIndex == 255) fgIndex = 19; +.LINE 275 CP A,255 JR NZ,L_66 LD A,19 LD (_fgIndex),A -; 278 } +; 276 } L_66: -.LINE 278 +.LINE 276 -; 279 if(kb_Data[7] & kb_Right) { -.LINE 279 +; 277 if(kb_Data[7] & kb_Right) { +.LINE 277 LD A,(16056350) AND A,4 JR Z,L_67 -; 280 fgIndex++; -.LINE 280 +; 278 fgIndex++; +.LINE 278 LD A,(_fgIndex) INC A LD (_fgIndex),A -; 281 if(fgIndex == 20) fgIndex = 0; -.LINE 281 +; 279 if(fgIndex == 20) fgIndex = 0; +.LINE 279 CP A,20 JR NZ,L_67 XOR A,A LD (_fgIndex),A -; 282 } +; 280 } L_67: -.LINE 282 +.LINE 280 -; 283 sprites_gfx_pal[1] = palette_colors[fgIndex]; -.LINE 283 +; 281 sprites_gfx_pal[1] = palette_colors[fgIndex]; +.LINE 281 LD A,(_fgIndex) UEXT HL @@ -2281,12 +2255,12 @@ L_67: LD (HL),C INC HL LD (HL),B -; 284 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); -.LINE 284 +; 282 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); +.LINE 282 LD BC,0 PUSH BC - LD BC,12 + LD BC,4 PUSH BC LD BC,_sprites_gfx_pal PUSH BC @@ -2294,8 +2268,8 @@ L_67: POP BC POP BC POP BC -; 285 drawPreview(170,135); -.LINE 285 +; 283 drawPreview(170,135); +.LINE 283 LD BC,135 PUSH BC @@ -2304,19 +2278,19 @@ L_67: CALL _drawPreview POP BC POP BC -; 286 } +; 284 } L_69: -.LINE 286 +.LINE 284 -; 287 gfx_SetColor(0x01); -.LINE 287 +; 285 gfx_SetColor(0x01); +.LINE 285 LD BC,1 PUSH BC CALL _gfx_SetColor POP BC -; 288 gfx_FillRectangle(153, 70, 8, 8); -.LINE 288 +; 286 gfx_FillRectangle(153, 70, 8, 8); +.LINE 286 LD BC,8 PUSH BC @@ -2330,8 +2304,8 @@ L_69: POP BC POP BC POP BC -; 289 gfx_SetColor(bgColor); -.LINE 289 +; 287 gfx_SetColor(bgColor); +.LINE 287 LD A,(_bgColor) LD C,A @@ -2339,61 +2313,61 @@ L_69: PUSH BC CALL _gfx_SetColor POP BC -; 290 -; 291 if(selected_option == 3) { -.LINE 291 +; 288 +; 289 if(selected_option == 3) { +.LINE 289 LD A,(IX+-1) CP A,3 JR NZ,L_79 -; 292 if(kb_Data[7] & kb_Left) { -.LINE 292 +; 290 if(kb_Data[7] & kb_Left) { +.LINE 290 LD A,(16056350) AND A,2 JR Z,L_76 -; 293 bgIndex--; -.LINE 293 +; 291 bgIndex--; +.LINE 291 LD A,(_bgIndex) DEC A LD (_bgIndex),A -; 294 if(bgIndex == 255) bgIndex = 19; -.LINE 294 +; 292 if(bgIndex == 255) bgIndex = 19; +.LINE 292 CP A,255 JR NZ,L_76 LD A,19 LD (_bgIndex),A -; 295 } +; 293 } L_76: -.LINE 295 +.LINE 293 -; 296 if(kb_Data[7] & kb_Right) { -.LINE 296 +; 294 if(kb_Data[7] & kb_Right) { +.LINE 294 LD A,(16056350) AND A,4 JR Z,L_77 -; 297 bgIndex++; -.LINE 297 +; 295 bgIndex++; +.LINE 295 LD A,(_bgIndex) INC A LD (_bgIndex),A -; 298 if(bgIndex == 20) bgIndex = 0; -.LINE 298 +; 296 if(bgIndex == 20) bgIndex = 0; +.LINE 296 CP A,20 JR NZ,L_77 XOR A,A LD (_bgIndex),A -; 299 } +; 297 } L_77: -.LINE 299 +.LINE 297 -; 300 sprites_gfx_pal[0] = palette_colors[bgIndex]; -.LINE 300 +; 298 sprites_gfx_pal[0] = palette_colors[bgIndex]; +.LINE 298 LD A,(_bgIndex) UEXT HL @@ -2406,12 +2380,12 @@ L_77: LD (HL),C INC HL LD (HL),B -; 301 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); -.LINE 301 +; 299 gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); +.LINE 299 LD BC,0 PUSH BC - LD BC,12 + LD BC,4 PUSH BC LD BC,_sprites_gfx_pal PUSH BC @@ -2419,8 +2393,8 @@ L_77: POP BC POP BC POP BC -; 302 drawPreview(170,135); -.LINE 302 +; 300 drawPreview(170,135); +.LINE 300 LD BC,135 PUSH BC @@ -2429,19 +2403,19 @@ L_77: CALL _drawPreview POP BC POP BC -; 303 } +; 301 } L_79: -.LINE 303 +.LINE 301 -; 304 gfx_SetColor(0x00); -.LINE 304 +; 302 gfx_SetColor(0x00); +.LINE 302 LD BC,0 PUSH BC CALL _gfx_SetColor POP BC -; 305 gfx_FillRectangle(153, 80, 8, 8); -.LINE 305 +; 303 gfx_FillRectangle(153, 80, 8, 8); +.LINE 303 LD BC,8 PUSH BC @@ -2455,8 +2429,8 @@ L_79: POP BC POP BC POP BC -; 306 gfx_SetColor(bgColor); -.LINE 306 +; 304 gfx_SetColor(bgColor); +.LINE 304 LD A,(_bgColor) LD C,A @@ -2464,9 +2438,9 @@ L_79: PUSH BC CALL _gfx_SetColor POP BC -; 307 -; 308 if(kb_Data[6] & kb_Clear || (selected_option == 5 && kb_Data[6] & kb_Enter)) { -.LINE 308 +; 305 +; 306 if(kb_Data[6] & kb_Clear || (selected_option == 5 && kb_Data[6] & kb_Enter)) { +.LINE 306 LD A,(16056348) AND A,64 @@ -2478,20 +2452,20 @@ L_79: AND A,1 JR NZ,L_83 JR L_94 -; 309 while(kb_Data[6] & kb_Clear || kb_Data[6] & kb_Enter) { +; 307 while(kb_Data[6] & kb_Clear || kb_Data[6] & kb_Enter) { L_84: -.LINE 309 +.LINE 307 -; 310 kb_ScanGroup(6); -.LINE 310 +; 308 kb_ScanGroup(6); +.LINE 308 LD BC,6 PUSH BC CALL _kb_ScanGroup POP BC -; 311 } +; 309 } L_83: -.LINE 311 +.LINE 309 LD A,(16056348) AND A,64 @@ -2499,21 +2473,21 @@ L_83: LD A,(16056348) AND A,1 JR NZ,L_84 -; 312 playing = false; -.LINE 312 +; 310 playing = false; +.LINE 310 XOR A,A LD (_playing),A -; 313 break; -.LINE 313 +; 311 break; +.LINE 311 JR L_100 -; 314 } +; 312 } L_94: -.LINE 314 +.LINE 312 -; 315 if(kb_Data[1] & kb_2nd || (selected_option == 4 && kb_Data[6] & kb_Enter)) { -.LINE 315 +; 313 if(kb_Data[1] & kb_2nd || (selected_option == 4 && kb_Data[6] & kb_Enter)) { +.LINE 313 LD A,(16056338) AND A,32 @@ -2525,17 +2499,17 @@ L_94: AND A,1 JR NZ,L_90 JR L_95 -; 316 while(kb_Data[1] & kb_2nd || kb_Data[6] & kb_Enter) { +; 314 while(kb_Data[1] & kb_2nd || kb_Data[6] & kb_Enter) { L_91: -.LINE 316 +.LINE 314 -; 317 kb_Scan(); -.LINE 317 +; 315 kb_Scan(); +.LINE 315 CALL _kb_Scan -; 318 } +; 316 } L_90: -.LINE 318 +.LINE 316 LD A,(16056338) AND A,32 @@ -2543,13 +2517,13 @@ L_90: LD A,(16056348) AND A,1 JR NZ,L_91 -; 319 paused = false; -.LINE 319 +; 317 paused = false; +.LINE 317 XOR A,A LD (_paused),A -; 320 gfx_SetColor(bgColor); -.LINE 320 +; 318 gfx_SetColor(bgColor); +.LINE 318 LD A,(_bgColor) LD C,A @@ -2557,8 +2531,8 @@ L_90: PUSH BC CALL _gfx_SetColor POP BC -; 321 gfx_FillScreen(bgColor); -.LINE 321 +; 319 gfx_FillScreen(bgColor); +.LINE 319 LD A,(_bgColor) LD C,A @@ -2566,12 +2540,12 @@ L_90: PUSH BC CALL _gfx_FillScreen POP BC -; 322 drawGraphics(); -.LINE 322 +; 320 drawGraphics(); +.LINE 320 CALL _drawGraphics -; 323 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); -.LINE 323 +; 321 gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); +.LINE 321 LD BC,220 PUSH BC @@ -2583,39 +2557,39 @@ L_90: POP BC POP BC POP BC -; 324 -; 325 ti_CloseAll(); -.LINE 325 +; 322 +; 323 ti_CloseAll(); +.LINE 323 CALL _ti_CloseAll -; 326 settings = ti_Open("C84SET", "w"); -.LINE 326 +; 324 settings = ti_Open("C84SET", "w"); +.LINE 324 - LD BC,L__86 + LD BC,L__85 PUSH BC - LD BC,L__87 + LD BC,L__86 PUSH BC CALL _ti_Open POP BC POP BC LD (_settings),A -; 327 data.fgColor = fgIndex; -.LINE 327 +; 325 data.fgColor = fgIndex; +.LINE 325 LD A,(_fgIndex) LD (_data),A -; 328 data.bgColor = bgIndex; -.LINE 328 +; 326 data.bgColor = bgIndex; +.LINE 326 LD A,(_bgIndex) LD (_data+1),A -; 329 data.cpf = cpf; -.LINE 329 +; 327 data.cpf = cpf; +.LINE 327 LD A,(_cpf) LD (_data+2),A -; 330 ti_Write(&data, sizeof(data_t), 1, settings); -.LINE 330 +; 328 ti_Write(&data, sizeof(data_t), 1, settings); +.LINE 328 LD A,(_settings) LD C,A @@ -2632,42 +2606,42 @@ L_90: POP BC POP BC POP BC -; 331 } +; 329 } L_95: -.LINE 331 +.LINE 329 -; 332 -; 333 gfx_BlitBuffer(); -.LINE 333 +; 330 +; 331 gfx_BlitBuffer(); +.LINE 331 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 334 delay(100); -.LINE 334 +; 332 delay(100); +.LINE 332 LD BC,100 PUSH BC CALL _delay POP BC -; 335 } +; 333 } L_96: -.LINE 335 +.LINE 333 LD A,(_paused) OR A,A JR NZ,L_97 -; 336 } -; 337 } while (playing); +; 334 } +; 335 } while (playing); L_100: -.LINE 337 +.LINE 335 LD A,(_playing) OR A,A JR NZ,L_99 -; 338 } -.LINE 338 +; 336 } +.LINE 336 LD SP,IX POP IX @@ -2686,7 +2660,7 @@ L_100: ;_kb_ScanGroup IMPORT ----- function ;_bgIndex STATIC 1 variable ;_gfx_SetPalette IMPORT ----- function -;_sprites_gfx_pal IMPORT 12 variable +;_sprites_gfx_pal IMPORT 8 variable ;_palette_colors STATIC 40 variable ;_fgIndex STATIC 1 variable ;_gfx_PrintUInt IMPORT ----- function @@ -2717,41 +2691,41 @@ L_100: ; Spill Code: 0 (instruction) -.ENDFUNC "startEmulation",338,"_startEmulation" +.ENDFUNC "startEmulation",336,"_startEmulation" SEGMENT STRSECT -L__47: +L__46: DB "Paused" DB 0 -L__48: +L__47: DB "Keymapping" DB 0 -L__49: +L__48: DB "Cycles per frame -" DB 0 -L__50: +L__49: DB "Foreground color -" DB 0 -L__51: +L__50: DB "Background color -" DB 0 -L__52: +L__51: DB "Resume" DB 0 -L__53: +L__52: DB "Quit game" DB 0 -L__58: +L__57: DB ">" DB 0 -L__86: +L__85: DB "w" DB 0 -L__87: +L__86: DB "C84SET" DB 0 SEGMENT CODE -; 339 -; 340 void beginKeymapper(char *fileName) { +; 337 +; 338 void beginKeymapper(char *fileName) { _beginKeymapper: .DEFINE "_beginKeymapper" @@ -2763,9 +2737,9 @@ _beginKeymapper: .ENDEF -.BEGFUNC "beginKeymapper",340,"_beginKeymapper" +.BEGFUNC "beginKeymapper",338,"_beginKeymapper" -.LINE 340 +.LINE 338 .DEFINE "fileName" @@ -2811,114 +2785,114 @@ _beginKeymapper: LD IX,0 ADD IX,SP PUSH BC -; 341 uint8_t selected = 0; -.LINE 341 +; 339 uint8_t selected = 0; +.LINE 339 LD (IX+-1),0 -; 342 uint8_t i; -; 343 bool awaiting = false; -.LINE 343 +; 340 uint8_t i; +; 341 bool awaiting = false; +.LINE 341 LD (IX+-3),0 -; 344 -; 345 drawKeymappingMenu(selected); -.LINE 345 +; 342 +; 343 drawKeymappingMenu(selected); +.LINE 343 LD BC,0 PUSH BC CALL _drawKeymappingMenu POP BC -; 346 -; 347 do { +; 344 +; 345 do { L_129: -.LINE 347 +.LINE 345 -; 348 kb_Scan(); -.LINE 348 +; 346 kb_Scan(); +.LINE 346 CALL _kb_Scan -; 349 if(!awaiting) { -.LINE 349 +; 347 if(!awaiting) { +.LINE 347 LD A,(IX+-3) OR A,A JR NZ,L_128 -; 350 if(kb_Data[7] & kb_Down) { -.LINE 350 +; 348 if(kb_Data[7] & kb_Down) { +.LINE 348 LD A,(16056350) AND A,1 JR Z,L_111 -; 351 selected++; -.LINE 351 +; 349 selected++; +.LINE 349 INC (IX+-1) -; 352 if(selected > 16) selected = 0; -.LINE 352 +; 350 if(selected > 16) selected = 0; +.LINE 350 LD A,16 CP A,(IX+-1) JR NC,L_104 LD (IX+-1),0 L_104: -; 353 drawKeymappingMenu(selected); -.LINE 353 +; 351 drawKeymappingMenu(selected); +.LINE 351 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawKeymappingMenu POP BC -; 354 } +; 352 } L_111: -.LINE 354 +.LINE 352 -; 355 if(kb_Data[7] & kb_Up) { -.LINE 355 +; 353 if(kb_Data[7] & kb_Up) { +.LINE 353 LD A,(16056350) AND A,8 JR Z,L_113 -; 356 if(selected == 0) -.LINE 356 +; 354 if(selected == 0) +.LINE 354 LD A,(IX+-1) OR A,A JR NZ,L_108 -; 357 selected = 16; -.LINE 357 +; 355 selected = 16; +.LINE 355 LD (IX+-1),16 -; 358 else -.LINE 358 +; 356 else +.LINE 356 JR L_109 L_108: -; 359 selected--; -.LINE 359 +; 357 selected--; +.LINE 357 DEC (IX+-1) L_109: -; 360 drawKeymappingMenu(selected); -.LINE 360 +; 358 drawKeymappingMenu(selected); +.LINE 358 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawKeymappingMenu POP BC -; 361 } +; 359 } L_113: -.LINE 361 +.LINE 359 -; 362 if(kb_Data[6] & kb_Enter) { -.LINE 362 +; 360 if(kb_Data[6] & kb_Enter) { +.LINE 360 LD A,(16056348) AND A,1 JR Z,L_120 -; 363 drawKeymappingMenu(selected+16); -.LINE 363 +; 361 drawKeymappingMenu(selected+16); +.LINE 361 LD A,(IX+-1) ADD A,16 @@ -2927,28 +2901,28 @@ L_113: PUSH BC CALL _drawKeymappingMenu POP BC -; 364 awaiting = 1; -.LINE 364 +; 362 awaiting = 1; +.LINE 362 LD (IX+-3),1 -; 365 } +; 363 } L_120: -.LINE 365 +.LINE 363 -; 366 if(kb_Data[1] & kb_2nd) { -.LINE 366 +; 364 if(kb_Data[1] & kb_2nd) { +.LINE 364 LD A,(16056338) AND A,32 JR Z,L_121 -; 367 for(i = 0; i < 16; i++) { -.LINE 367 +; 365 for(i = 0; i < 16; i++) { +.LINE 365 LD (IX+-2),0 JR L_117 L_115: -; 368 game_data[i+6] = i; -.LINE 368 +; 366 game_data[i+6] = i; +.LINE 366 LD A,(IX+-2) UEXT HL @@ -2959,8 +2933,8 @@ L_115: ADD HL,BC LD A,(IX+-2) LD (HL),A -; 369 controlMap[i] = i; -.LINE 369 +; 367 controlMap[i] = i; +.LINE 367 LD A,(IX+-2) UEXT HL @@ -2970,159 +2944,159 @@ L_115: LD A,(IX+-2) LD (HL),A INC (IX+-2) -; 370 } +; 368 } L_117: -.LINE 370 +.LINE 368 LD A,(IX+-2) CP A,16 JR C,L_115 -; 371 drawKeymappingMenu(selected); -.LINE 371 +; 369 drawKeymappingMenu(selected); +.LINE 369 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawKeymappingMenu POP BC -; 372 } +; 370 } L_121: -.LINE 372 +.LINE 370 -; 373 delay(100); -.LINE 373 +; 371 delay(100); +.LINE 371 LD BC,100 PUSH BC CALL _delay POP BC -; 374 } else { -.LINE 374 +; 372 } else { +.LINE 372 JR L_130 L_128: -; 375 keypad[0x0] = kb_Data[4] & kb_DecPnt; -.LINE 375 +; 373 keypad[0x0] = kb_Data[4] & kb_DecPnt; +.LINE 373 LD A,(16056344) AND A,1 LD (_keypad),A -; 376 keypad[0x1] = kb_Data[3] & kb_7; -.LINE 376 +; 374 keypad[0x1] = kb_Data[3] & kb_7; +.LINE 374 LD A,(16056342) AND A,8 LD HL,_keypad INC HL LD (HL),A -; 377 keypad[0x2] = kb_Data[4] & kb_8; -.LINE 377 +; 375 keypad[0x2] = kb_Data[4] & kb_8; +.LINE 375 LD A,(16056344) AND A,8 LD IY,_keypad LEA HL,IY+2 LD (HL),A -; 378 keypad[0x3] = kb_Data[5] & kb_9; -.LINE 378 +; 376 keypad[0x3] = kb_Data[5] & kb_9; +.LINE 376 LD A,(16056346) AND A,8 LEA HL,IY+3 LD (HL),A -; 379 keypad[0x4] = kb_Data[3] & kb_4; -.LINE 379 +; 377 keypad[0x4] = kb_Data[3] & kb_4; +.LINE 377 LD A,(16056342) AND A,4 LEA HL,IY+4 LD (HL),A -; 380 keypad[0x5] = kb_Data[4] & kb_5; -.LINE 380 +; 378 keypad[0x5] = kb_Data[4] & kb_5; +.LINE 378 LD A,(16056344) AND A,4 LEA HL,IY+5 LD (HL),A -; 381 keypad[0x6] = kb_Data[5] & kb_6; -.LINE 381 +; 379 keypad[0x6] = kb_Data[5] & kb_6; +.LINE 379 LD A,(16056346) AND A,4 LEA HL,IY+6 LD (HL),A -; 382 keypad[0x7] = kb_Data[3] & kb_1; -.LINE 382 +; 380 keypad[0x7] = kb_Data[3] & kb_1; +.LINE 380 LD A,(16056342) AND A,2 LEA HL,IY+7 LD (HL),A -; 383 keypad[0x8] = kb_Data[4] & kb_2; -.LINE 383 +; 381 keypad[0x8] = kb_Data[4] & kb_2; +.LINE 381 LD A,(16056344) AND A,2 LEA HL,IY+8 LD (HL),A -; 384 keypad[0x9] = kb_Data[5] & kb_3; -.LINE 384 +; 382 keypad[0x9] = kb_Data[5] & kb_3; +.LINE 382 LD A,(16056346) AND A,2 LEA HL,IY+9 LD (HL),A -; 385 keypad[0xA] = kb_Data[3] & kb_0; -.LINE 385 +; 383 keypad[0xA] = kb_Data[3] & kb_0; +.LINE 383 LD A,(16056342) AND A,1 LEA HL,IY+10 LD (HL),A -; 386 keypad[0xB] = kb_Data[5] & kb_Chs; -.LINE 386 +; 384 keypad[0xB] = kb_Data[5] & kb_Chs; +.LINE 384 LD A,(16056346) AND A,1 LEA HL,IY+11 LD (HL),A -; 387 keypad[0xC] = kb_Data[6] & kb_Mul; -.LINE 387 +; 385 keypad[0xC] = kb_Data[6] & kb_Mul; +.LINE 385 LD A,(16056348) AND A,8 LEA HL,IY+12 LD (HL),A -; 388 keypad[0xD] = kb_Data[6] & kb_Sub; -.LINE 388 +; 386 keypad[0xD] = kb_Data[6] & kb_Sub; +.LINE 386 LD A,(16056348) AND A,4 LEA HL,IY+13 LD (HL),A -; 389 keypad[0xE] = kb_Data[6] & kb_Add; -.LINE 389 +; 387 keypad[0xE] = kb_Data[6] & kb_Add; +.LINE 387 LD A,(16056348) AND A,2 LEA HL,IY+14 LD (HL),A -; 390 keypad[0xF] = kb_Data[6] & kb_Enter; -.LINE 390 +; 388 keypad[0xF] = kb_Data[6] & kb_Enter; +.LINE 388 LD A,(16056348) AND A,1 LEA HL,IY+15 LD (HL),A -; 391 -; 392 for(i = 0; i < 16; i++) { -.LINE 392 +; 389 +; 390 for(i = 0; i < 16; i++) { +.LINE 390 LD (IX+-2),0 JR L_126 L_124: -; 393 if(keypad[i]) { -.LINE 393 +; 391 if(keypad[i]) { +.LINE 391 LD A,(IX+-2) UEXT HL @@ -3132,8 +3106,8 @@ L_124: LD A,(HL) OR A,A JR Z,L_125 -; 394 game_data[selected+6] = i; -.LINE 394 +; 392 game_data[selected+6] = i; +.LINE 392 LD A,(IX+-1) UEXT HL @@ -3144,8 +3118,8 @@ L_124: ADD HL,BC LD A,(IX+-2) LD (HL),A -; 395 controlMap[selected] = i; -.LINE 395 +; 393 controlMap[selected] = i; +.LINE 393 LD A,(IX+-1) UEXT HL @@ -3154,65 +3128,65 @@ L_124: ADD HL,BC LD A,(IX+-2) LD (HL),A -; 396 awaiting = 0; -.LINE 396 +; 394 awaiting = 0; +.LINE 394 LD (IX+-3),0 -; 397 drawKeymappingMenu(selected); -.LINE 397 +; 395 drawKeymappingMenu(selected); +.LINE 395 LD C,(IX+-1) LD B,0 PUSH BC CALL _drawKeymappingMenu POP BC -; 398 } -; 399 } +; 396 } +; 397 } L_125: -.LINE 399 +.LINE 397 INC (IX+-2) L_126: LD A,(IX+-2) CP A,16 JR C,L_124 -; 400 } -; 401 } while(kb_Data[6] != kb_Clear); +; 398 } +; 399 } while(kb_Data[6] != kb_Clear); L_130: -.LINE 401 +.LINE 399 LD A,(16056348) CP A,64 JR NZ,L_129 -; 402 -; 403 while(kb_Data[6] & kb_Clear) { -.LINE 403 +; 400 +; 401 while(kb_Data[6] & kb_Clear) { +.LINE 401 JR L_131 L_132: -; 404 kb_ScanGroup(6); -.LINE 404 +; 402 kb_ScanGroup(6); +.LINE 402 LD BC,6 PUSH BC CALL _kb_ScanGroup POP BC -; 405 } +; 403 } L_131: -.LINE 405 +.LINE 403 LD A,(16056348) AND A,64 JR NZ,L_132 -; 406 -; 407 ti_CloseAll(); -.LINE 407 +; 404 +; 405 ti_CloseAll(); +.LINE 405 CALL _ti_CloseAll -; 408 curFile = ti_Open(fileName, "w"); -.LINE 408 +; 406 curFile = ti_Open(fileName, "w"); +.LINE 406 - LD BC,L__103 + LD BC,L__102 PUSH BC LD BC,(IX+6) PUSH BC @@ -3220,8 +3194,8 @@ L_131: POP BC POP BC LD (_curFile),A -; 409 ti_Write(&game_data, sizeof(game_data)/sizeof(uint8_t), 1, curFile); -.LINE 409 +; 407 ti_Write(&game_data, sizeof(game_data)/sizeof(uint8_t), 1, curFile); +.LINE 407 LD C,A LD B,0 @@ -3237,9 +3211,9 @@ L_131: POP BC POP BC POP BC -; 410 -; 411 gfx_FillScreen(bgColor); -.LINE 411 +; 408 +; 409 gfx_FillScreen(bgColor); +.LINE 409 LD A,(_bgColor) LD C,A @@ -3247,20 +3221,20 @@ L_131: PUSH BC CALL _gfx_FillScreen POP BC -; 412 gfx_BlitBuffer(); -.LINE 412 +; 410 gfx_BlitBuffer(); +.LINE 410 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 413 paused = false; -.LINE 413 +; 411 paused = false; +.LINE 411 XOR A,A LD (_paused),A -; 414 } -.LINE 414 +; 412 } +.LINE 412 LD SP,IX POP IX @@ -3294,14 +3268,14 @@ L_131: ; Spill Code: 0 (instruction) -.ENDFUNC "beginKeymapper",414,"_beginKeymapper" +.ENDFUNC "beginKeymapper",412,"_beginKeymapper" SEGMENT STRSECT -L__103: +L__102: DB "w" DB 0 SEGMENT CODE -; 415 -; 416 void drawKeymappingMenu(uint8_t selected) { +; 413 +; 414 void drawKeymappingMenu(uint8_t selected) { _drawKeymappingMenu: .DEFINE "_drawKeymappingMenu" @@ -3313,9 +3287,9 @@ _drawKeymappingMenu: .ENDEF -.BEGFUNC "drawKeymappingMenu",416,"_drawKeymappingMenu" +.BEGFUNC "drawKeymappingMenu",414,"_drawKeymappingMenu" -.LINE 416 +.LINE 414 .DEFINE "selected" @@ -3341,9 +3315,9 @@ _drawKeymappingMenu: LD IX,0 ADD IX,SP DEC SP -; 417 uint8_t i; -; 418 gfx_FillScreen(bgColor); -.LINE 418 +; 415 uint8_t i; +; 416 gfx_FillScreen(bgColor); +.LINE 416 LD A,(_bgColor) LD C,A @@ -3351,15 +3325,15 @@ _drawKeymappingMenu: PUSH BC CALL _gfx_FillScreen POP BC -; 419 -; 420 for(i = 0; i < 16; i++) { -.LINE 420 +; 417 +; 418 for(i = 0; i < 16; i++) { +.LINE 418 LD (IX+-1),0 JR L_139 L_137: -; 421 gfx_PrintStringXY("Key", 30, i*10+10); -.LINE 421 +; 419 gfx_PrintStringXY("Key", 30, i*10+10); +.LINE 419 LD A,(IX+-1) UEXT HL @@ -3371,14 +3345,14 @@ L_137: PUSH BC LD BC,30 PUSH BC - LD BC,L__105 + LD BC,L__104 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 422 gfx_SetTextXY(60, i*10+10); -.LINE 422 +; 420 gfx_SetTextXY(60, i*10+10); +.LINE 420 LD A,(IX+-1) UEXT HL @@ -3393,8 +3367,8 @@ L_137: CALL _gfx_SetTextXY POP BC POP BC -; 423 gfx_PrintUInt(i, 2); -.LINE 423 +; 421 gfx_PrintUInt(i, 2); +.LINE 421 LD BC,2 PUSH BC @@ -3405,8 +3379,8 @@ L_137: CALL _gfx_PrintUInt POP BC POP BC -; 424 gfx_PrintStringXY(keyNames[game_data[i+6]], 90, i*10+10); -.LINE 424 +; 422 gfx_PrintStringXY(keyNames[game_data[i+6]], 90, i*10+10); +.LINE 422 LD A,(IX+-1) UEXT HL @@ -3440,56 +3414,56 @@ L_137: POP BC POP BC INC (IX+-1) -; 425 } +; 423 } L_139: -.LINE 425 +.LINE 423 LD A,(IX+-1) CP A,16 JR C,L_137 -; 426 -; 427 gfx_PrintStringXY("Select a key to remap, then press the new key.", 10, 200); -.LINE 427 +; 424 +; 425 gfx_PrintStringXY("Select a key to remap, then press the new key.", 10, 200); +.LINE 425 LD BC,200 PUSH BC LD BC,10 PUSH BC - LD BC,L__107 + LD BC,L__106 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 428 gfx_PrintStringXY("Press 2nd to reset, clear to exit.", 10, 215); -.LINE 428 +; 426 gfx_PrintStringXY("Press 2nd to reset, clear to exit.", 10, 215); +.LINE 426 LD BC,215 PUSH BC LD BC,10 PUSH BC - LD BC,L__108 + LD BC,L__107 PUSH BC CALL _gfx_PrintStringXY POP BC POP BC POP BC -; 429 -; 430 gfx_SetColor(0x03); -.LINE 430 +; 427 +; 428 gfx_SetColor(0x03); +.LINE 428 LD BC,3 PUSH BC CALL _gfx_SetColor POP BC -; 431 if(selected > 16) { -.LINE 431 +; 429 if(selected > 16) { +.LINE 429 LD A,16 CP A,(IX+6) JR NC,L_142 -; 432 gfx_Circle(13, (selected%16)*10+13, 3); -.LINE 432 +; 430 gfx_Circle(13, (selected%16)*10+13, 3); +.LINE 430 LD BC,3 PUSH BC @@ -3509,13 +3483,13 @@ L_139: POP BC POP BC POP BC -; 433 } else { -.LINE 433 +; 431 } else { +.LINE 431 JR L_143 L_142: -; 434 gfx_FillRectangle(10, (selected%16)*10+10, 6, 6); -.LINE 434 +; 432 gfx_FillRectangle(10, (selected%16)*10+10, 6, 6); +.LINE 432 LD BC,6 PUSH BC @@ -3537,20 +3511,20 @@ L_142: POP BC POP BC POP BC -; 435 } +; 433 } L_143: -.LINE 435 +.LINE 433 -; 436 -; 437 gfx_BlitBuffer(); -.LINE 437 +; 434 +; 435 gfx_BlitBuffer(); +.LINE 435 LD BC,1 PUSH BC CALL _gfx_Blit POP BC -; 438 } -.LINE 438 +; 436 } +.LINE 436 LD SP,IX POP IX @@ -3578,20 +3552,20 @@ L_143: ; Spill Code: 0 (instruction) -.ENDFUNC "drawKeymappingMenu",438,"_drawKeymappingMenu" +.ENDFUNC "drawKeymappingMenu",436,"_drawKeymappingMenu" SEGMENT STRSECT -L__105: +L__104: DB "Key" DB 0 -L__107: +L__106: DB "Select a key to remap, then press the new key." DB 0 -L__108: +L__107: DB "Press 2nd to reset, clear to exit." DB 0 SEGMENT CODE -; 439 -; 440 void drawGraphics() { +; 437 +; 438 void drawGraphics() { _drawGraphics: .DEFINE "_drawGraphics" @@ -3603,25 +3577,25 @@ _drawGraphics: .ENDEF -.BEGFUNC "drawGraphics",440,"_drawGraphics" +.BEGFUNC "drawGraphics",438,"_drawGraphics" PUSH IX LD IX,0 ADD IX,SP -; 441 drawFlag = false; -.LINE 441 +; 439 drawFlag = 0; +.LINE 439 XOR A,A LD (_drawFlag),A -; 442 -; 443 if(extendedScreen) -.LINE 443 +; 440 +; 441 if(extendedScreen) +.LINE 441 LD A,(_extendedScreen) OR A,A JR Z,L_146 -; 444 gfx_ScaledSprite_NoClip(scanvas, 30, 55, 2, 2); -.LINE 444 +; 442 gfx_ScaledSprite_NoClip(canvas, 30, 55, 2, 2); +.LINE 442 LD BC,2 PUSH BC @@ -3630,7 +3604,7 @@ _drawGraphics: PUSH BC LD BC,30 PUSH BC - LD BC,_scanvas_data + LD BC,_canvas_data PUSH BC CALL _gfx_ScaledSprite_NoClip POP BC @@ -3638,13 +3612,13 @@ _drawGraphics: POP BC POP BC POP BC -; 445 else -.LINE 445 +; 443 else +.LINE 443 JR L_147 L_146: -; 446 gfx_ScaledSprite_NoClip(canvas, 30, 55, 4, 4); -.LINE 446 +; 444 gfx_ScaledSprite_NoClip(canvas, 30, 55, 4, 4); +.LINE 444 LD BC,4 PUSH BC @@ -3661,9 +3635,9 @@ L_146: POP BC POP BC POP BC -; 447 } +; 445 } L_147: -.LINE 447 +.LINE 445 LD SP,IX POP IX @@ -3672,8 +3646,7 @@ L_147: ;**************************** _drawGraphics *************************** ;Name Addr/Register Size Type -;_canvas_data IMPORT 2050 variable -;_scanvas_data IMPORT 8194 variable +;_canvas_data IMPORT 8194 variable ;_gfx_ScaledSprite_NoClip IMPORT ----- function ;_extendedScreen IMPORT 1 variable ;_drawFlag IMPORT 1 variable @@ -3683,9 +3656,9 @@ L_147: ; Spill Code: 0 (instruction) -.ENDFUNC "drawGraphics",447,"_drawGraphics" -; 448 -; 449 void drawPreview(uint8_t x, uint8_t y) { +.ENDFUNC "drawGraphics",445,"_drawGraphics" +; 446 +; 447 void drawPreview(uint8_t x, uint8_t y) { _drawPreview: .DEFINE "_drawPreview" @@ -3697,9 +3670,9 @@ _drawPreview: .ENDEF -.BEGFUNC "drawPreview",449,"_drawPreview" +.BEGFUNC "drawPreview",447,"_drawPreview" -.LINE 449 +.LINE 447 .DEFINE "x" @@ -3724,20 +3697,20 @@ _drawPreview: PUSH IX LD IX,0 ADD IX,SP -; 450 drawFlag = false; -.LINE 450 +; 448 drawFlag = 0; +.LINE 448 XOR A,A LD (_drawFlag),A -; 451 -; 452 if(extendedScreen) -.LINE 452 +; 449 +; 450 if(extendedScreen) +.LINE 450 LD A,(_extendedScreen) OR A,A JR Z,L_149 -; 453 gfx_Sprite_NoClip(scanvas, x, y); -.LINE 453 +; 451 gfx_Sprite_NoClip(canvas, x, y); +.LINE 451 LD C,(IX+9) LD B,0 @@ -3746,19 +3719,19 @@ _drawPreview: UEXT HL LD L,A PUSH HL - LD BC,_scanvas_data + LD BC,_canvas_data PUSH BC CALL _gfx_Sprite_NoClip POP BC POP BC POP BC -; 454 else -.LINE 454 +; 452 else +.LINE 452 JR L_150 L_149: -; 455 gfx_ScaledSprite_NoClip(canvas, x, y, 2, 2); -.LINE 455 +; 453 gfx_ScaledSprite_NoClip(canvas, x, y, 2, 2); +.LINE 453 LD BC,2 PUSH BC @@ -3779,7 +3752,7 @@ L_149: POP BC POP BC L_150: -.LINE 456 +.LINE 454 LD SP,IX POP IX @@ -3788,9 +3761,8 @@ L_150: ;**************************** _drawPreview *************************** ;Name Addr/Register Size Type -;_canvas_data IMPORT 2050 variable ;_gfx_ScaledSprite_NoClip IMPORT ----- function -;_scanvas_data IMPORT 8194 variable +;_canvas_data IMPORT 8194 variable ;_gfx_Sprite_NoClip IMPORT ----- function ;_extendedScreen IMPORT 1 variable ;_drawFlag IMPORT 1 variable @@ -3802,9 +3774,8 @@ L_150: ; Spill Code: 0 (instruction) -.ENDFUNC "drawPreview",456,"_drawPreview" +.ENDFUNC "drawPreview",454,"_drawPreview" XREF _sprites_gfx_pal:ROM - XREF _scanvas_data:ROM XREF _canvas_data:ROM XREF _emulateCycle:ROM XREF _loadProgram:ROM @@ -3834,8 +3805,6 @@ L_150: XREF _gfx_End:ROM XREF _gfx_Begin:ROM XREF _strcpy:ROM - XREF _sprintf:ROM - XREF _ti_GetSize:ROM XREF _ti_Rewind:ROM XREF _ti_Read:ROM XREF _ti_Write:ROM @@ -3845,7 +3814,6 @@ L_150: XREF _boot_Set48MHzMode:ROM XREF _delay:ROM XREF __irems:ROM - XREF __stoiu:ROM XREF __icmpzero:ROM XREF __imul_b:ROM XDEF _drawPreview diff --git a/obj/sprites_gfx.src b/obj/sprites_gfx.src index 6c2d871..3951d6d 100644 --- a/obj/sprites_gfx.src +++ b/obj/sprites_gfx.src @@ -10,13 +10,11 @@ _sprites_gfx_pal: DW 65535 DW 0 DW 65535 - DW 54025 - DW 7429 .DEFINE "sprites_gfx_pal" .ALIAS "_sprites_gfx_pal" .CLASS 69 .VALUE _sprites_gfx_pal -.DIM 6 +.DIM 4 .TYPE 109 .ENDEF XDEF _sprites_gfx_pal @@ -24,5 +22,5 @@ _sprites_gfx_pal: ; 2 #include ; 3 #include "sprites_gfx.h" ; 4 -; 5 uint16_t sprites_gfx_pal[6] = { +; 5 uint16_t sprites_gfx_pal[4] = { END diff --git a/screenshots/demo.png b/screenshots/demo.png new file mode 100644 index 0000000..b864945 Binary files /dev/null and b/screenshots/demo.png differ diff --git a/src/backup/chip8.c.nope b/src/backup/chip8.c.nope new file mode 100644 index 0000000..bc0df0e --- /dev/null +++ b/src/backup/chip8.c.nope @@ -0,0 +1,559 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "chip8.h" +#include "sprites_gfx.h" + +uint16_t opcode = 0; +uint8_t memory[4096]; +uint8_t SV[8]; +uint8_t V[16]; +uint16_t I = 0; +uint16_t pc = 0; +int16_t delay_timer = 0; +int16_t sound_timer = 0; +uint16_t stack[16]; +uint8_t sp = 0; +uint8_t keys[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +bool drawFlag = false; + +bool paused = false; +bool playing = false; +bool extendedScreen = 0; + +uint8_t game_data[3584]; +uint8_t keypad[16]; +uint8_t controlMap[16]; + +ti_var_t file; + +unsigned char fontset[80] = { + 0xF0, 0x90, 0x90, 0x90, 0xF0, //0 + 0x20, 0x60, 0x20, 0x20, 0x70, //1 + 0xF0, 0x10, 0xF0, 0x80, 0xF0, //2 + 0xF0, 0x10, 0xF0, 0x10, 0xF0, //3 + 0x90, 0x90, 0xF0, 0x10, 0x10, //4 + 0xF0, 0x80, 0xF0, 0x10, 0xF0, //5 + 0xF0, 0x80, 0xF0, 0x90, 0xF0, //6 + 0xF0, 0x10, 0x20, 0x40, 0x40, //7 + 0xF0, 0x90, 0xF0, 0x90, 0xF0, //8 + 0xF0, 0x90, 0xF0, 0x10, 0xF0, //9 + 0xF0, 0x90, 0xF0, 0x90, 0x90, //A + 0xE0, 0x90, 0xE0, 0x90, 0xE0, //B + 0xF0, 0x80, 0x80, 0x80, 0xF0, //C + 0xE0, 0x90, 0x90, 0x90, 0xE0, //D + 0xF0, 0x80, 0xF0, 0x80, 0xF0, //E + 0xF0, 0x80, 0xF0, 0x80, 0x80 //F +}; +uint16_t fontset_ten[80] = { + 0xC67C, 0xDECE, 0xF6D6, 0xC6E6, 0x007C, // 0 + 0x3010, 0x30F0, 0x3030, 0x3030, 0x00FC, // 1 + 0xCC78, 0x0CCC, 0x3018, 0xCC60, 0x00FC, // 2 + 0xCC78, 0x0C0C, 0x0C38, 0xCC0C, 0x0078, // 3 + 0x1C0C, 0x6C3C, 0xFECC, 0x0C0C, 0x001E, // 4 + 0xC0FC, 0xC0C0, 0x0CF8, 0xCC0C, 0x0078, // 5 + 0x6038, 0xC0C0, 0xCCF8, 0xCCCC, 0x0078, // 6 + 0xC6FE, 0x06C6, 0x180C, 0x3030, 0x0030, // 7 + 0xCC78, 0xECCC, 0xDC78, 0xCCCC, 0x0078, // 8 + 0xC67C, 0xC6C6, 0x0C7E, 0x3018, 0x0070, // 9 + 0x7830, 0xCCCC, 0xFCCC, 0xCCCC, 0x00CC, // A + 0x66FC, 0x6666, 0x667C, 0x6666, 0x00FC, // B + 0x663C, 0xC0C6, 0xC0C0, 0x66C6, 0x003C, // C + 0x6CF8, 0x6666, 0x6666, 0x6C66, 0x00F8, // D + 0x62FE, 0x6460, 0x647C, 0x6260, 0x00FE, // E + 0x66FE, 0x6462, 0x647C, 0x6060, 0x00F0 // F +}; + +uint8_t step; +uint16_t pixel; +uint16_t index; + +uint8_t _y; +uint8_t _x; + +uint8_t screen_width; +uint8_t screen_height; + +void initialize() { + + opcode = I = sp = delay_timer = sound_timer = 0; + pc = 0x200; + + extendedScreen = 0; + screen_width = 64; + screen_height = 32; + + scanvas_data[0] = 128; + scanvas_data[1] = 64; + memset(scanvas_data + 2, 0, 8192); + + canvas_data[0] = 64; + canvas_data[1] = 32; + memset(canvas_data + 2, 0, 2048); + + memset(keys, 0, 16); + memset(stack, 0, 16); + memset(V, 0, 16); + memset(SV, 0, 8); + memset(memory, 0, 4096); + + memcpy(memory, fontset, 80); + memcpy(memory + 80, fontset_ten, 80); + + srand(rtc_Time()); +} + +void loadProgram(char *fileName) { + int i; + uint16_t romSize; + + playing = true; + paused = false; + + ti_CloseAll(); + file = ti_Open(fileName, "r"); + ti_Read(&game_data, ti_GetSize(file), 1, file); + + romSize = ti_GetSize(file)-(16+6); + + initialize(); + + if((4096-512) > romSize) { + for(i = 0; i < romSize; ++i) { + memory[i + 512] = (uint8_t)game_data[i+16+6]; + } + } + for(i = 0; i < 16; i++) { + controlMap[i] = (uint8_t)game_data[i+6]; + } +} + +void setKeys() { + keypad[0x0] = kb_Data[4] & kb_DecPnt; + keypad[0x1] = kb_Data[3] & kb_7; + keypad[0x2] = kb_Data[4] & kb_8; + keypad[0x3] = kb_Data[5] & kb_9; + keypad[0x4] = kb_Data[3] & kb_4; + keypad[0x5] = kb_Data[4] & kb_5; + keypad[0x6] = kb_Data[5] & kb_6; + keypad[0x7] = kb_Data[3] & kb_1; + keypad[0x8] = kb_Data[4] & kb_2; + keypad[0x9] = kb_Data[5] & kb_3; + keypad[0xA] = kb_Data[3] & kb_0; + keypad[0xB] = kb_Data[5] & kb_Chs; + keypad[0xC] = kb_Data[6] & kb_Mul; + keypad[0xD] = kb_Data[6] & kb_Sub; + keypad[0xE] = kb_Data[6] & kb_Add; + keypad[0xF] = kb_Data[6] & kb_Enter; + + keys[0x0] = keypad[controlMap[0x0]]; + keys[0x1] = keypad[controlMap[0x1]]; + keys[0x2] = keypad[controlMap[0x2]]; + keys[0x3] = keypad[controlMap[0x3]]; + + keys[0x4] = keypad[controlMap[0x4]]; + keys[0x5] = keypad[controlMap[0x5]]; + keys[0x6] = keypad[controlMap[0x6]]; + keys[0x7] = keypad[controlMap[0x7]]; + + keys[0x8] = keypad[controlMap[0x8]]; + keys[0x9] = keypad[controlMap[0x9]]; + keys[0xA] = keypad[controlMap[0xA]]; + keys[0xB] = keypad[controlMap[0xB]]; + + keys[0xC] = keypad[controlMap[0xC]]; + keys[0xD] = keypad[controlMap[0xD]]; + keys[0xE] = keypad[controlMap[0xE]]; + keys[0xF] = keypad[controlMap[0xF]]; + + if(kb_Data[1] & kb_2nd) { + while(kb_Data[1] & kb_2nd) { + kb_Scan(); + } + paused = 1; + } +} + +void emulateCycle(uint8_t steps) { + + kb_Scan(); + setKeys(); + + for(step = 0; step < steps; ++step) { + int i; + uint8_t x; + uint8_t y; + opcode = (memory[pc] << 8) | memory[pc+1]; + x = (opcode & 0x0f00) >> 8; + y = (opcode & 0x00f0) >> 4; + + pc += 2; + + switch(opcode & 0xf000) { + case 0x0000: { + switch(opcode & 0x00f0) { + case 0x00c0: { //SCD + uint8_t n = (opcode & 0x000f); + uint8_t *disp; + + if(extendedScreen) { + disp = &scanvas_data[2]; + } else { + disp = &canvas_data[2]; + } + for(i = screen_height-2; i >= 0; i--) { + memcpy(disp + (i+n)*screen_width, disp + i*screen_width, screen_width); + memset(disp + i*screen_width, 0, screen_width); + } + + drawFlag = true; + + break; + } + break; + } + switch(opcode & 0x00ff) { + case 0x00e0: + if(extendedScreen) + memset(scanvas_data + 2, 0, 8192); + else + memset(canvas_data + 2, 0, 2048); + drawFlag = true; + break; + case 0x00ee: + pc = stack[(--sp)&0xf]; + break; + case 0x00fb: { //SCR + uint8_t *disp; + + if(extendedScreen) { + disp = &scanvas_data[2]; + } else { + disp = &canvas_data[2]; + } + for(i = 0; i < screen_height; i++) { + memmove(disp + 4, disp, screen_width - 4); + memset(disp, 0, 4); + disp += screen_width; + } + break; + } + case 0x00fc: { //SCL + uint8_t *disp; + + if(extendedScreen) { + disp = &scanvas_data[2]; + } else { + disp = &canvas_data[2]; + } + for(i = 0; i < screen_height; i++) { + memmove(disp, disp + 4, screen_width - 4); + memset(disp + screen_width - 4, 0, 4); + disp += screen_width; + } + break; + } + case 0x00fd: + playing = 0; + //exit + break; + case 0x00fe: + extendedScreen = 0; + screen_width = 64; + screen_height = 32; + memcpy(canvas_data + 2, scanvas_data + 2, 2048); + dbg_sprintf(dbgout, "Extended mode off\n"); + break; + case 0x00ff: + extendedScreen = 1; + screen_width = 128; + screen_height = 64; + memcpy(scanvas_data + 2, canvas_data + 2, 2048); + dbg_sprintf(dbgout, "Extended mode on\n"); + break; + default: + pc = (pc & 0x0fff); + break; + } + break; + } + case 0x1000: { + pc = (opcode & 0x0fff); + break; + } + case 0x2000: { + stack[sp++] = pc; + pc = (opcode & 0x0fff); + break; + } + case 0x3000: { + if(V[x] == (opcode & 0x00ff)) + pc += 2; + break; + } + case 0x4000: { + if(V[x] != (opcode & 0x00ff)) + pc += 2; + break; + } + case 0x5000: { + if(V[x] == V[y]) + pc += 2; + break; + } + case 0x6000: { + V[x] = (opcode & 0x00ff); + break; + } + case 0x7000: { + V[x] = (V[x] + (opcode & 0x00ff)) & 0xff; + break; + } + case 0x8000: { + switch(opcode & 0x000f) { + case 0x0000: { + V[x] = V[y]; + break; + } + case 0x0001: { + V[x] |= V[y]; + break; + } + case 0x0002: { + V[x] &= V[y]; + break; + } + case 0x0003: { + V[x] ^= V[y]; + break; + } + case 0x0004: { + V[0xf] = (V[x] + V[y] > 0xff); + V[x] += V[y]; + V[x] &= 255; + break; + } + case 0x0005: { + V[0xf] = V[x] >= V[y]; + V[x] -= V[y]; + break; + } + case 0x0006: { + V[0xf] = V[x] & 1; + V[x] >>= 1; + break; + } + case 0x0007: { + V[0xf] = V[y] >= V[x]; + V[x] = V[y] - V[x]; + break; + } + case 0x000E: { + V[0xf] = V[x] >> 7; + V[x] <<= 1; + break; + } + break; + } + break; + } + case 0x9000: { + if(V[x] != V[y]) + pc += 2; + break; + } + case 0xa000: { + I = (opcode & 0x0fff); + break; + } + case 0xb000: { + pc = V[0] + (opcode & 0x0fff); + break; + } + case 0xc000: { + V[x] = (rand() & 0xff) & (opcode & 0x00FF); + break; + } + case 0xd000: { + uint8_t xd = V[x]; + uint8_t yd = V[y]; + uint8_t height = (opcode & 0x000f); + + V[0xf] = 0; + + if(extendedScreen) { + //Extended screen DXY0 + uint8_t cols = 1; + if(height == 0) { + cols = 2; + height = 16; + } + for(_y = 0; _y < height; ++_y) { + pixel = memory[I + (cols*_y)]; + if(cols == 2) { + pixel <<= 8; + pixel |= memory[I + (_y << 1)+1]; + } + for(_x = 0; _x < (cols << 3); ++_x) { + if((pixel & (((cols == 2) ? 0x8000 : 0x80) >> _x)) != 0) { + index = (((xd + _x) & 0x7f) + (((yd + _y) & 0x3f) << 7)) + 2; + V[0xf] |= scanvas_data[index] & 1; + if (scanvas_data[index]) + scanvas_data[index] = 0; + else + scanvas_data[index] = 1; + } + } + } + } else { + //Normal screen DXYN + if(height == 0) height = 16; + for(_y = 0; _y < height; ++_y) { + pixel = memory[I + _y]; + for(_x = 0; _x < 8; ++_x) { + if((pixel & (0x80 >> _x)) != 0) { + index = (((xd + _x) & 0x3f) + (((yd + _y) & 0x1f) << 6)) + 2; + V[0xf] |= canvas_data[index] & 1; + if (canvas_data[index]) + canvas_data[index] = 0; + else + canvas_data[index] = 1; + } + } + } + } + + drawFlag = true; + + break; + } + case 0xe000: { + switch(opcode & 0x00ff) { + case 0x009e: { + if(keys[V[x]]) + pc += 2; + break; + } + case 0x00a1: { + if(!keys[V[x]]) + pc += 2; + break; + } + } + break; + } + case 0xf000: { + switch(opcode & 0x00ff) { + case 0x0007: { + V[x] = delay_timer; + break; + } + case 0x000A: { + bool key_pressed = false; + pc -= 2; + + for(i = 0; i < 16; ++i) { + if(keys[i]) { + V[x] = i; + pc += 2; + key_pressed = true; + break; + } + } + + if(!key_pressed) + return; + } + case 0x0015: { + delay_timer = V[x]; + break; + } + case 0x0018: { + sound_timer = V[x]; + break; + } + case 0x001E: { + I = (I + V[x]) & 0xffff; + break; + } + case 0x0029: { + I = (V[x] & 0xf) * 5; + break; + } + case 0x0030: { + I = (V[x] & 0xf) * 10 + 80; + break; + } + case 0x0033: { + memory[ I ] = V[x] / 100; + memory[I+1] = (V[x] / 10) % 10; + memory[I+2] = V[x] % 10; + break; + } + case 0x0055: { + for(i = 0; i <= x; ++i) { + memory[I + i] = V[i]; + } + break; + } + case 0x0065: { + for(i = 0; i <= x; ++i) { + V[i] = memory[I + i]; + } + break; + } + case 0x0075: { + if (x > 7) x = 7; + for(i = 0; i <= x; ++i) { + SV[i] = V[i]; + } + break; + } + case 0x0085: { + if (x > 7) x = 7; + for(i = 0; i <= x; ++i) { + V[i] = SV[i]; + } + break; + } + } + break; + } + default: + break; + } + } + if(sound_timer > 0) { + --sound_timer; + } + if(delay_timer > 0) { + --delay_timer; + } +} + + + + + + + + + + + + + + + + diff --git a/src/backup/main.c.nope b/src/backup/main.c.nope new file mode 100644 index 0000000..4e587b6 --- /dev/null +++ b/src/backup/main.c.nope @@ -0,0 +1,456 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "chip8.h" +#include "sprites_gfx.h" + +void drawGraphics(void); +void startEmulation(char *fileName); +void drawMenu(uint8_t start); +void drawKeymappingMenu(uint8_t selected); +void beginKeymapper(char *fileName); +void beginSetClock(void); +void drawPreview(uint8_t x, uint8_t y); + +ti_var_t curFile; + +char files[255][9]; +uint8_t count; + +uint8_t bgColor = 0x88; +uint8_t cpf = 10; + +uint8_t frameCount = 0; + +uint8_t fgIndex = 1; +uint8_t bgIndex = 0; + +const char *pauseText = "[2nd] - Pause"; +const char *keyNames[16] = { + "Decimal", + "Seven", + "Eight", + "Nine", + "Four", + "Five", + "Six", + "One", + "Two", + "Three", + "Zero", + "Negative", + "Times", + "Plus", + "Minus", + "Enter" +}; + +const uint16_t palette_colors[20] = { + 0x0000, // 00 :: rgb(0,0,1) + 0x37BD, // 01 :: rgb(108,234,239) + 0xAC43, // 02 :: rgb(92,21,21) + 0x916C, // 03 :: rgb(30,95,97) + 0x90CE, // 04 :: rgb(35,51,113) + 0xFFFF, // 05 :: rgb(255,255,255) + 0xFFEE, // 06 :: rgb(255,253,113) + 0xB63F, // 07 :: rgb(111,141,253) + 0x0CE3, // 08 :: rgb(25,55,25) + 0xDEF7, // 09 :: rgb(191,191,191) + 0xB5A4, // 10 :: rgb(110,109,34) + 0xFDDF, // 11 :: rgb(255,118,253) + 0x5DFF, // 12 :: rgb(188,122,255) + 0xB06C, // 13 :: rgb(98,28,97) + 0x28E2, // 14 :: rgb(80,58,18) + 0xFF0C, // 15 :: rgb(252,197,102) + 0xA06C, // 16 :: rgb(63,28,99) + 0xE508, // 17 :: rgb(203,68,68) + 0x36AD, // 18 :: rgb(110,172,110) + 0x14A5, // 19 :: rgb(39,39,39) +}; + +ti_var_t settings; +typedef struct { + uint8_t fgColor; + uint8_t bgColor; + uint8_t cpf; +} data_t; +data_t data; + +void main(void) { + uint8_t i; + char *varName; + uint8_t *search_pos = NULL; + uint8_t startPos = 0; + uint8_t test1[16] = {0x00,0x01,0x02,0x03,0x06,0x05,0x04,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; + + boot_Set48MHzMode(); + + ti_CloseAll(); + settings = ti_Open("C84SET", "r"); + dbg_sprintf(dbgout, "%d", ti_GetSize(settings)); + if(settings == 0) { + ti_CloseAll(); + settings = ti_Open("C84SET", "w"); + data.fgColor = 0x1; + data.bgColor = 0x0; + data.cpf = 20; + ti_Write(&data, sizeof(data_t), 1, settings); + ti_Rewind(settings); + } + ti_Read(&data, sizeof(data_t), 1, settings); + fgIndex = data.fgColor; + bgIndex = data.bgColor; + cpf = data.cpf; + sprites_gfx_pal[0] = palette_colors[bgIndex]; + sprites_gfx_pal[1] = palette_colors[fgIndex]; + + count = 0; + + gfx_Begin(gfx_8bpp); + gfx_Blit(gfx_screen); + gfx_SetDrawBuffer(); + gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); + gfx_SetColor(0x03); + + gfx_SetTextFGColor(0x02); + gfx_SetTextScale(2, 2); + gfx_PrintStringXY("Chip-84", 103, 95); + gfx_SetTextScale(1, 1); + gfx_PrintStringXY("2018 Christian Kosman", 80, 120); + gfx_PrintStringXY("version 2.3.0", LCD_WIDTH-100, LCD_HEIGHT-30); + gfx_BlitBuffer(); + + delay(1000); + + while((varName = ti_Detect(&search_pos, "Chip84")) != NULL) { + strcpy(files[count], varName); + ++count; + } + + drawMenu(0); + + do { + kb_Scan(); + + if(kb_Data[7] & kb_Up) { + frameCount = 0; + if(startPos == 0) + startPos = count-1; + else + startPos--; + drawMenu(startPos); + } else if(kb_Data[7] & kb_Down) { + frameCount = 0; + if(startPos == count-1) + startPos = 0; + else + startPos++; + drawMenu(startPos); + } else if(kb_Data[6] & kb_Enter) { + gfx_FillScreen(0xFF); + startEmulation(files[startPos]); + drawMenu(startPos); + } + + if(frameCount > 9) { + if(frameCount < 100) { + frameCount = 101; + loadProgram(files[startPos]); + gfx_PrintStringXY("Preview", 187, 60); + } + emulateCycle(20); + + if(drawFlag) + drawPreview(150, 70); + } else { + frameCount++; + delay(100); + } + + gfx_BlitBuffer(); + } while (kb_Data[6] != kb_Clear); + + gfx_End(); +} + +void drawMenu(uint8_t start) { + uint8_t i; + gfx_FillScreen(0xff); + gfx_SetTextFGColor(0x02); + for(i = 0; i < 16; i++) { + if(i + start <= count-1) { + gfx_PrintStringXY(files[i+start], 30, 10*i+50); + } + } + gfx_PrintStringXY(">",20,50); + + gfx_SetTextScale(2,2); + gfx_PrintStringXY("Select a ROM", 20, 20); + gfx_SetTextScale(1,1); + gfx_PrintStringXY("[clear] - Quit", 220, 220); + +} + +void startEmulation(char *fileName) { + + loadProgram(fileName); + + gfx_FillScreen(bgColor); + gfx_SetTextFGColor(0x03); + gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); + + do { + emulateCycle(cpf); + + if(drawFlag) + drawGraphics(); + + gfx_BlitBuffer(); + if(paused) { + uint8_t selected_option = 0; + + gfx_FillScreen(bgColor); + drawPreview(170,135); + gfx_SetTextScale(2, 2); + gfx_PrintStringXY("Paused", 20, 20); + gfx_SetTextScale(1, 1); + gfx_PrintStringXY("Keymapping", 20, 50); + gfx_PrintStringXY("Cycles per frame -", 20, 60); + gfx_PrintStringXY("Foreground color -", 20, 70); + gfx_PrintStringXY("Background color -", 20, 80); + gfx_PrintStringXY("Resume", 20, 90); + gfx_PrintStringXY("Quit game", 20, 100); + gfx_BlitBuffer(); + gfx_SetColor(bgColor); + while(paused) { + kb_Scan(); + + gfx_FillRectangle(10, 50 + selected_option*10, 10, 10); + + if(kb_Data[7] & kb_Up) { + selected_option--; + if(selected_option == 255) selected_option = 5; + } + if(kb_Data[7] & kb_Down) { + selected_option++; + if(selected_option == 6) selected_option = 0; + } + + gfx_PrintStringXY(">", 10, 50 + selected_option*10); + + if(selected_option == 0) { + if(kb_Data[6] & kb_Enter) { + beginKeymapper(fileName); + gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); + } + } + + if(selected_option == 1) { + if(kb_Data[7] & kb_Left) { + cpf--; + if(cpf == 0) cpf = 50; + } + if(kb_Data[7] & kb_Right) { + cpf++; + if(cpf == 51) cpf = 1; + } + } + gfx_FillRectangle(150, 60, 30, 30); + gfx_SetTextXY(150, 60); + gfx_PrintUInt(cpf, 2); + + if(selected_option == 2) { + if(kb_Data[7] & kb_Left) { + fgIndex--; + if(fgIndex == 255) fgIndex = 19; + } + if(kb_Data[7] & kb_Right) { + fgIndex++; + if(fgIndex == 20) fgIndex = 0; + } + sprites_gfx_pal[1] = palette_colors[fgIndex]; + gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); + drawPreview(170,135); + } + gfx_SetColor(0x01); + gfx_FillRectangle(153, 70, 8, 8); + gfx_SetColor(bgColor); + + if(selected_option == 3) { + if(kb_Data[7] & kb_Left) { + bgIndex--; + if(bgIndex == 255) bgIndex = 19; + } + if(kb_Data[7] & kb_Right) { + bgIndex++; + if(bgIndex == 20) bgIndex = 0; + } + sprites_gfx_pal[0] = palette_colors[bgIndex]; + gfx_SetPalette(sprites_gfx_pal, sizeof_sprites_gfx_pal, 0); + drawPreview(170,135); + } + gfx_SetColor(0x00); + gfx_FillRectangle(153, 80, 8, 8); + gfx_SetColor(bgColor); + + if(kb_Data[6] & kb_Clear || (selected_option == 5 && kb_Data[6] & kb_Enter)) { + while(kb_Data[6] & kb_Clear || kb_Data[6] & kb_Enter) { + kb_ScanGroup(6); + } + playing = false; + break; + } + if(kb_Data[1] & kb_2nd || (selected_option == 4 && kb_Data[6] & kb_Enter)) { + while(kb_Data[1] & kb_2nd || kb_Data[6] & kb_Enter) { + kb_Scan(); + } + paused = false; + gfx_SetColor(bgColor); + gfx_FillScreen(bgColor); + drawGraphics(); + gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); + + ti_CloseAll(); + settings = ti_Open("C84SET", "w"); + data.fgColor = fgIndex; + data.bgColor = bgIndex; + data.cpf = cpf; + ti_Write(&data, sizeof(data_t), 1, settings); + } + + gfx_BlitBuffer(); + delay(100); + } + } + } while (playing); +} + +void beginKeymapper(char *fileName) { + uint8_t selected = 0; + uint8_t i; + bool awaiting = false; + + drawKeymappingMenu(selected); + + do { + kb_Scan(); + if(!awaiting) { + if(kb_Data[7] & kb_Down) { + selected++; + if(selected > 16) selected = 0; + drawKeymappingMenu(selected); + } + if(kb_Data[7] & kb_Up) { + if(selected == 0) + selected = 16; + else + selected--; + drawKeymappingMenu(selected); + } + if(kb_Data[6] & kb_Enter) { + drawKeymappingMenu(selected+16); + awaiting = 1; + } + if(kb_Data[1] & kb_2nd) { + for(i = 0; i < 16; i++) { + game_data[i+6] = i; + controlMap[i] = i; + } + drawKeymappingMenu(selected); + } + delay(100); + } else { + keypad[0x0] = kb_Data[4] & kb_DecPnt; + keypad[0x1] = kb_Data[3] & kb_7; + keypad[0x2] = kb_Data[4] & kb_8; + keypad[0x3] = kb_Data[5] & kb_9; + keypad[0x4] = kb_Data[3] & kb_4; + keypad[0x5] = kb_Data[4] & kb_5; + keypad[0x6] = kb_Data[5] & kb_6; + keypad[0x7] = kb_Data[3] & kb_1; + keypad[0x8] = kb_Data[4] & kb_2; + keypad[0x9] = kb_Data[5] & kb_3; + keypad[0xA] = kb_Data[3] & kb_0; + keypad[0xB] = kb_Data[5] & kb_Chs; + keypad[0xC] = kb_Data[6] & kb_Mul; + keypad[0xD] = kb_Data[6] & kb_Sub; + keypad[0xE] = kb_Data[6] & kb_Add; + keypad[0xF] = kb_Data[6] & kb_Enter; + + for(i = 0; i < 16; i++) { + if(keypad[i]) { + game_data[selected+6] = i; + controlMap[selected] = i; + awaiting = 0; + drawKeymappingMenu(selected); + } + } + } + } while(kb_Data[6] != kb_Clear); + + while(kb_Data[6] & kb_Clear) { + kb_ScanGroup(6); + } + + ti_CloseAll(); + curFile = ti_Open(fileName, "w"); + ti_Write(&game_data, sizeof(game_data)/sizeof(uint8_t), 1, curFile); + + gfx_FillScreen(bgColor); + gfx_BlitBuffer(); + paused = false; +} + +void drawKeymappingMenu(uint8_t selected) { + uint8_t i; + gfx_FillScreen(bgColor); + + for(i = 0; i < 16; i++) { + gfx_PrintStringXY("Key", 30, i*10+10); + gfx_SetTextXY(60, i*10+10); + gfx_PrintUInt(i, 2); + gfx_PrintStringXY(keyNames[game_data[i+6]], 90, i*10+10); + } + + gfx_PrintStringXY("Select a key to remap, then press the new key.", 10, 200); + gfx_PrintStringXY("Press 2nd to reset, clear to exit.", 10, 215); + + gfx_SetColor(0x03); + if(selected > 16) { + gfx_Circle(13, (selected%16)*10+13, 3); + } else { + gfx_FillRectangle(10, (selected%16)*10+10, 6, 6); + } + + gfx_BlitBuffer(); +} + +void drawGraphics() { + drawFlag = 0; + + if(extendedScreen) + gfx_ScaledSprite_NoClip(scanvas, 30, 55, 2, 2); + else + gfx_ScaledSprite_NoClip(canvas, 30, 55, 4, 4); +} + +void drawPreview(uint8_t x, uint8_t y) { + drawFlag = 0; + + if(extendedScreen) + gfx_Sprite_NoClip(scanvas, x, y); + else + gfx_ScaledSprite_NoClip(canvas, x, y, 2, 2); +} \ No newline at end of file diff --git a/src/canvas.c b/src/canvas.c deleted file mode 100644 index f46ed13..0000000 --- a/src/canvas.c +++ /dev/null @@ -1,7 +0,0 @@ -// Converted using ConvPNG -#include -#include "sprites_gfx.h" - -// 8 bpp image -uint8_t canvas_data[2050]; -uint8_t scanvas_data[8194]; \ No newline at end of file diff --git a/src/chip8.c b/src/chip8.c index bc0df0e..89d59bc 100644 --- a/src/chip8.c +++ b/src/chip8.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -16,7 +15,7 @@ #include "sprites_gfx.h" uint16_t opcode = 0; -uint8_t memory[4096]; +uint8_t memory[0x1000]; uint8_t SV[8]; uint8_t V[16]; uint16_t I = 0; @@ -31,8 +30,10 @@ bool drawFlag = false; bool paused = false; bool playing = false; bool extendedScreen = 0; +uint8_t plane = 1; uint8_t game_data[3584]; +uint8_t canvas_data[8194]; uint8_t keypad[16]; uint8_t controlMap[16]; @@ -84,6 +85,7 @@ uint8_t _x; uint8_t screen_width; uint8_t screen_height; +uint8_t pixel_number; void initialize() { @@ -93,14 +95,10 @@ void initialize() { extendedScreen = 0; screen_width = 64; screen_height = 32; - - scanvas_data[0] = 128; - scanvas_data[1] = 64; - memset(scanvas_data + 2, 0, 8192); canvas_data[0] = 64; canvas_data[1] = 32; - memset(canvas_data + 2, 0, 2048); + memset(canvas_data + 2, 0, 8192); memset(keys, 0, 16); memset(stack, 0, 16); @@ -125,13 +123,13 @@ void loadProgram(char *fileName) { file = ti_Open(fileName, "r"); ti_Read(&game_data, ti_GetSize(file), 1, file); - romSize = ti_GetSize(file)-(16+6); + romSize = ti_GetSize(file)-22; initialize(); if((4096-512) > romSize) { for(i = 0; i < romSize; ++i) { - memory[i + 512] = (uint8_t)game_data[i+16+6]; + memory[i + 512] = (uint8_t)game_data[i+22]; } } for(i = 0; i < 16; i++) { @@ -140,6 +138,8 @@ void loadProgram(char *fileName) { } void setKeys() { + uint8_t i; + keypad[0x0] = kb_Data[4] & kb_DecPnt; keypad[0x1] = kb_Data[3] & kb_7; keypad[0x2] = kb_Data[4] & kb_8; @@ -157,25 +157,9 @@ void setKeys() { keypad[0xE] = kb_Data[6] & kb_Add; keypad[0xF] = kb_Data[6] & kb_Enter; - keys[0x0] = keypad[controlMap[0x0]]; - keys[0x1] = keypad[controlMap[0x1]]; - keys[0x2] = keypad[controlMap[0x2]]; - keys[0x3] = keypad[controlMap[0x3]]; - - keys[0x4] = keypad[controlMap[0x4]]; - keys[0x5] = keypad[controlMap[0x5]]; - keys[0x6] = keypad[controlMap[0x6]]; - keys[0x7] = keypad[controlMap[0x7]]; - - keys[0x8] = keypad[controlMap[0x8]]; - keys[0x9] = keypad[controlMap[0x9]]; - keys[0xA] = keypad[controlMap[0xA]]; - keys[0xB] = keypad[controlMap[0xB]]; - - keys[0xC] = keypad[controlMap[0xC]]; - keys[0xD] = keypad[controlMap[0xD]]; - keys[0xE] = keypad[controlMap[0xE]]; - keys[0xF] = keypad[controlMap[0xF]]; + for(i = 0; i < 15; i++) { + keys[i] = keypad[controlMap[i]]; + } if(kb_Data[1] & kb_2nd) { while(kb_Data[1] & kb_2nd) { @@ -205,13 +189,8 @@ void emulateCycle(uint8_t steps) { switch(opcode & 0x00f0) { case 0x00c0: { //SCD uint8_t n = (opcode & 0x000f); - uint8_t *disp; + uint8_t *disp = &canvas_data[2]; - if(extendedScreen) { - disp = &scanvas_data[2]; - } else { - disp = &canvas_data[2]; - } for(i = screen_height-2; i >= 0; i--) { memcpy(disp + (i+n)*screen_width, disp + i*screen_width, screen_width); memset(disp + i*screen_width, 0, screen_width); @@ -225,23 +204,15 @@ void emulateCycle(uint8_t steps) { } switch(opcode & 0x00ff) { case 0x00e0: - if(extendedScreen) - memset(scanvas_data + 2, 0, 8192); - else - memset(canvas_data + 2, 0, 2048); + memset(canvas_data + 2, 0, pixel_number); drawFlag = true; break; case 0x00ee: pc = stack[(--sp)&0xf]; break; case 0x00fb: { //SCR - uint8_t *disp; + uint8_t *disp = &canvas_data[2]; - if(extendedScreen) { - disp = &scanvas_data[2]; - } else { - disp = &canvas_data[2]; - } for(i = 0; i < screen_height; i++) { memmove(disp + 4, disp, screen_width - 4); memset(disp, 0, 4); @@ -250,13 +221,8 @@ void emulateCycle(uint8_t steps) { break; } case 0x00fc: { //SCL - uint8_t *disp; + uint8_t *disp = &canvas_data[2]; - if(extendedScreen) { - disp = &scanvas_data[2]; - } else { - disp = &canvas_data[2]; - } for(i = 0; i < screen_height; i++) { memmove(disp, disp + 4, screen_width - 4); memset(disp + screen_width - 4, 0, 4); @@ -272,15 +238,17 @@ void emulateCycle(uint8_t steps) { extendedScreen = 0; screen_width = 64; screen_height = 32; - memcpy(canvas_data + 2, scanvas_data + 2, 2048); - dbg_sprintf(dbgout, "Extended mode off\n"); + canvas_data[0] = 64; + canvas_data[1] = 32; + pixel_number = 2048; break; case 0x00ff: extendedScreen = 1; screen_width = 128; screen_height = 64; - memcpy(scanvas_data + 2, canvas_data + 2, 2048); - dbg_sprintf(dbgout, "Extended mode on\n"); + canvas_data[0] = 128; + canvas_data[1] = 64; + pixel_number = 8192; break; default: pc = (pc & 0x0fff); @@ -408,11 +376,11 @@ void emulateCycle(uint8_t steps) { for(_x = 0; _x < (cols << 3); ++_x) { if((pixel & (((cols == 2) ? 0x8000 : 0x80) >> _x)) != 0) { index = (((xd + _x) & 0x7f) + (((yd + _y) & 0x3f) << 7)) + 2; - V[0xf] |= scanvas_data[index] & 1; - if (scanvas_data[index]) - scanvas_data[index] = 0; + V[0xf] |= canvas_data[index] & 1; + if (canvas_data[index]) + canvas_data[index] = 0; else - scanvas_data[index] = 1; + canvas_data[index] = 1; } } } diff --git a/src/chip8.h b/src/chip8.h index 769854a..73dbee4 100644 --- a/src/chip8.h +++ b/src/chip8.h @@ -1,8 +1,6 @@ #include #include #include -#include -#include #include #include @@ -10,7 +8,7 @@ #include extern uint16_t opcode; -extern uint8_t memory[4096]; +extern uint8_t memory[0x1000]; extern uint8_t SV[8]; extern uint8_t V[16]; extern uint16_t I; @@ -25,6 +23,11 @@ extern bool drawFlag; extern bool paused; extern bool playing; extern bool extendedScreen; +extern uint8_t plane; + +extern uint8_t screen_width; +extern uint8_t screen_height; +extern uint8_t pixel_number; extern ti_var_t file; diff --git a/src/main.c b/src/main.c index c4e8f92..c8384e9 100644 --- a/src/main.c +++ b/src/main.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -99,7 +98,6 @@ void main(void) { ti_CloseAll(); settings = ti_Open("C84SET", "r"); - dbg_sprintf(dbgout, "%d", ti_GetSize(settings)); if(settings == 0) { ti_CloseAll(); settings = ti_Open("C84SET", "w"); @@ -129,7 +127,7 @@ void main(void) { gfx_PrintStringXY("Chip-84", 103, 95); gfx_SetTextScale(1, 1); gfx_PrintStringXY("2018 Christian Kosman", 80, 120); - gfx_PrintStringXY("version 2.3.0", LCD_WIDTH-100, LCD_HEIGHT-30); + gfx_PrintStringXY("version 2.3.1", LCD_WIDTH-100, LCD_HEIGHT-30); gfx_BlitBuffer(); delay(1000); @@ -208,7 +206,7 @@ void startEmulation(char *fileName) { loadProgram(fileName); gfx_FillScreen(bgColor); - gfx_SetTextFGColor(0x03); + gfx_SetTextFGColor(254); gfx_PrintStringXY(pauseText, 10, LCD_HEIGHT-20); do { @@ -438,19 +436,19 @@ void drawKeymappingMenu(uint8_t selected) { } void drawGraphics() { - drawFlag = false; + drawFlag = 0; if(extendedScreen) - gfx_ScaledSprite_NoClip(scanvas, 30, 55, 2, 2); + gfx_ScaledSprite_NoClip(canvas, 30, 55, 2, 2); else gfx_ScaledSprite_NoClip(canvas, 30, 55, 4, 4); } void drawPreview(uint8_t x, uint8_t y) { - drawFlag = false; + drawFlag = 0; if(extendedScreen) - gfx_Sprite_NoClip(scanvas, x, y); + gfx_Sprite_NoClip(canvas, x, y); else gfx_ScaledSprite_NoClip(canvas, x, y, 2, 2); } \ No newline at end of file diff --git a/src/rom/schip8/C83DTITL b/src/rom/schip8/C83DTITL new file mode 100644 index 0000000..2d98514 Binary files /dev/null and b/src/rom/schip8/C83DTITL differ diff --git a/src/sprites_gfx.c b/src/sprites_gfx.c index 9a0278e..bb34cdc 100644 --- a/src/sprites_gfx.c +++ b/src/sprites_gfx.c @@ -2,11 +2,9 @@ #include #include "sprites_gfx.h" -uint16_t sprites_gfx_pal[6] = { +uint16_t sprites_gfx_pal[4] = { 0x0000, // 00 :: rgb(0,0,1) black - 0xFFFF, // 04 :: rgb(255,255,255) white - 0x0000, // Static black - 0xFFFF, // Static white - 0xD309, // 01 :: rgb(168,198,78) lcd_bg - 0x1D05, // 05 :: rgb(60,65,44) lcd_fg + 0xFFFF, // 01 :: rgb(255,255,255) white + 0x0000, // 02 Static black + 0xFFFF, // 03 Static white }; \ No newline at end of file diff --git a/src/sprites_gfx.h b/src/sprites_gfx.h index 337ea8e..4c66ecf 100644 --- a/src/sprites_gfx.h +++ b/src/sprites_gfx.h @@ -4,19 +4,13 @@ #define __sprites_gfx__ #include -#define canvas_width 64 -#define canvas_height 32 -#define canvas_size 2050 -extern uint8_t canvas_data[2050]; +#define canvas_width 128 +#define canvas_height 64 +#define canvas_size 8194 +extern uint8_t canvas_data[8194]; #define canvas ((gfx_sprite_t*)canvas_data) -#define scanvas_width 128 -#define scanvas_height 64 -#define scanvas_size 8194 -extern uint8_t scanvas_data[8194]; -#define scanvas ((gfx_sprite_t*)scanvas_data) - -#define sizeof_sprites_gfx_pal 12 -extern uint16_t sprites_gfx_pal[6]; +#define sizeof_sprites_gfx_pal 4 +extern uint16_t sprites_gfx_pal[4]; #endif \ No newline at end of file