diff --git a/core/banks.asm b/core/banks.asm index 9e7bcd5..f7c58cd 100644 --- a/core/banks.asm +++ b/core/banks.asm @@ -20,20 +20,20 @@ EXTERN init_battery SECTION .text -; * Inicia ponteiros dos bancos -; ******************************* +; * Initialize banks pointers +; ***************************** GLOBAL init_banks init_banks: push edi - ; Limpa a NEAR [RAM] + ; Clear RAM xor eax, eax mov BYTE [battery], al mov ecx, (40*1024)/4 - mov edi, RAM ; mov edi, offset RAM + mov edi, RAM rep stosd - ; Inicia ponteiros dos bancos e registradores de paginação + ; Initialize banks pointers and page registers mov BYTE [RAMSelect], al mov eax, DWORD [ROM] mov DWORD [pBank0], eax @@ -49,11 +49,11 @@ init_banks: pop edi ret -; * Ler a memória -; ***************** +; * Read memory +; *************** GLOBAL read_mem read_mem: - ; Qual banco vai ler? + ; Which bank? cmp esi, 00400h jb RM0 cmp esi, 04000h @@ -63,12 +63,12 @@ read_mem: cmp esi, 0C000h jb RM3 - ; Ler a NEAR [RAM] ou registradores de paginação + ; Read RAM or page register and esi, 0DFFFh - add esi, RAM - 0C000h ; add esi, offset RAM - 0C000h + add esi, RAM - 0C000h ret - ; Seleciona o banco para leitura + ; Select the right bank RM0: add esi, DWORD [ROM] ret RM1: add esi, DWORD [pBank0] @@ -78,26 +78,26 @@ RM2: add esi, DWORD [pBank1] RM3: add esi, DWORD [pBank2] ret -; * Escreve na memória -; ********************** +; * Write memory +; **************** GLOBAL write_mem write_mem: - ; Qual banco vai escrever? + ; Which bank? cmp esi, 08000h jb WM7 cmp esi, 0C000h jb WM8 - ; Escrever nos registradores de paginação? + ; Write in page registers? cmp esi, 0FFFCh jae WM1 - ; Escreve na NEAR [RAM] + ; Write in RAM WM0: and esi, 0DFFFh - add esi, RAM - 0C000h ; add esi, offset RAM - 0C000h + add esi, RAM - 0C000h ret - ; NEAR [RAM] Select + ; Select WM1: cmp esi, 0FFFCh jne WM4 mov BYTE [RAMSelect], al @@ -107,7 +107,7 @@ WM1: cmp esi, 0FFFCh mov DWORD [pBank2], ebx jmp WM0 - ; Inicia bateria + ; Initialize battery WM11: cmp BYTE [battery], 0 jne WM2 push eax @@ -115,7 +115,7 @@ WM11: cmp BYTE [battery], 0 pop eax mov BYTE [battery], 1 - ; Seleciona o banco da bateria + ; Select battery bank WM2: test al, 4 jnz WM3 mov DWORD [pBank2], RAM_EX - 08000h @@ -123,7 +123,7 @@ WM2: test al, 4 WM3: mov DWORD [pBank2], RAM_EX - 04000h jmp WM0 - ; Seleciona a página para o banco do DWORD [ROM] + ; Select ROM page WM4: mov ebx, eax mov ah, 0 div BYTE [ROM_size] @@ -131,14 +131,14 @@ WM4: mov ebx, eax shl eax, 14 add eax, DWORD [ROM] - ; Banco 0 + ; Bank 0 cmp esi, 0FFFDh jne WM5 mov DWORD [pBank0], eax mov eax, ebx jmp WM0 - ; Banco 1 + ; Bank 1 WM5: cmp esi, 0FFFEh jne WM6 sub eax, 04000h @@ -146,7 +146,7 @@ WM5: cmp esi, 0FFFEh mov eax, ebx jmp WM0 - ; Banco 2 + ; Bank 2 WM6: sub eax, 08000h mov DWORD [pBank2ROM], eax test BYTE [RAMSelect], 8 @@ -155,7 +155,7 @@ WM6: sub eax, 08000h WM66: mov eax, ebx jmp WM0 - ; Escreve no banco selecionado + ; Write in selected bank WM7: mov esi, garbage ret WM8: test BYTE [RAMSelect], 8 diff --git a/core/cpu.asm b/core/cpu.asm index 74ba0bc..b9c614b 100644 --- a/core/cpu.asm +++ b/core/cpu.asm @@ -25,8 +25,8 @@ EXTERN ?OpCodeErr3@@YAXHHHH@Z SECTION .text -; * Reseta a CPU -; **************** +; * Reset CPU +; ************* GLOBAL reset_CPU reset_CPU: xor eax, eax @@ -46,8 +46,8 @@ reset_CPU: ret -; * Processa uma linha -; ********************** +; * Executes one line +; ********************* GLOBAL TraceLine TraceLine: inc BYTE [rR] @@ -60,32 +60,32 @@ TLF: cmp BYTE [TClock], 228 jb TraceLine ret -; * Executa interrupção BYTE [NMI] (Botão pause) -; ***************************************** +; * NMI Interruption (pause button) +; *********************************** GLOBAL int_NMI int_NMI: pusha - ; Guarda máscara de interrupção + ; Save interruption mask mov BYTE [NMI], 1 mov al, BYTE [IFF1] mov BYTE [IFF2], al mov BYTE [IFF1], 0 - ; Verifica o estado da CPU + ; Checks CPU state test BYTE [Halt], 1 jz NMI0 mov BYTE [Halt], 0 inc DWORD [rPCx] - ; Empilha PC + ; push PC NMI0: sub DWORD [rSPx], 2 mov esi, DWORD [rSPx] call read_mem mov eax, DWORD [rPCx] mov [esi], ax - ; Endereço da interrupção + ; Jump to interruption address inc BYTE [rR] mov DWORD [rPCx], 66h add BYTE [TClock], 11 @@ -93,39 +93,39 @@ NMI0: sub DWORD [rSPx], 2 popa ret -; * Executa interrupção -; *********************** +; * Z80 Interruption +; ******************** GLOBAL int_Z80 int_Z80: - ; Verifica se a interrupção está abilitada + ; Checks if the interruption is enabled cmp BYTE [IFF1], 0 je IZ80 - ; Reseta máscaras de interrupção + ; Reset interruption mask mov BYTE [IFF1], 0 mov BYTE [IFF2], 0 - ; Verifica o estado da CPU + ; Checks CPU state test BYTE [Halt], 1 jz Z80 mov BYTE [Halt], 0 inc DWORD [rPCx] - ; Empilha PC + ; push PC Z80: sub DWORD [rSPx], 2 mov esi, DWORD [rSPx] call read_mem mov eax, DWORD [rPCx] mov [esi], ax - ; Endereço da interrupção + ; Jump to interruption address inc BYTE [rR] mov DWORD [rPCx], 38h add BYTE [TClock], 13 IZ80: ret -; * Opcode não implementado -; *************************** +; * Opcode not implemented (one byte) +; ************************************* GLOBAL _NIMP1 _NIMP1: ;pusha @@ -136,8 +136,8 @@ _NIMP1: ;popa jmp TLF -; * Opcode não implementado -; *************************** +; * Opcode not implemented (two bytes) +; ************************************** GLOBAL _NIMP2 _NIMP2: ;pusha @@ -150,8 +150,8 @@ _NIMP2: ;popa jmp TLF -; * Opcode não implementado -; *************************** +; * Opcode not implemented (three bytes) +; **************************************** GLOBAL _NIMP3 _NIMP3: ;pusha @@ -166,7 +166,7 @@ _NIMP3: ;popa jmp TLF -; * Opcode não Listado +; * Opcode not listed ; ********************** GLOBAL _NOLIST _NOLIST: @@ -200,7 +200,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Increment register %1 +; * Increment register r ; ************************ %MACRO __INCr 2 and BYTE [Flag], 1 @@ -240,7 +240,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Decrement register pair %1 +; * Decrement register pair ss ; ****************************** %MACRO __DECss 1 dec WORD %1 @@ -282,7 +282,7 @@ _NOLIST: __LDrr %1, [esi], 7 %ENDMACRO -; * Load location (HL) with register %1 +; * Load location (HL) with register r ; ************************************** %MACRO __LD_HL_r 1 mov al, %1 @@ -310,7 +310,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Add operand %1 to accumulator with carry +; * Add operand s to accumulator with carry ; ******************************************* %MACRO __ADCAs 2 mov bl, BYTE [Flag] @@ -328,7 +328,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Subtract operand %1 from accumulator +; * Subtract operand s from accumulator ; *************************************** %MACRO __SUBs 2 mov BYTE [Flag], 2 @@ -344,7 +344,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Subtract operand %1 from accumulator with carry +; * Subtract operand s from accumulator with carry ; ************************************************** %MACRO __SBCAs 2 mov bl, BYTE [Flag] @@ -362,7 +362,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Logical AND of operand %1 to accumulator +; * Logical AND of operand s to accumulator ; ******************************************* %MACRO __ANDs 2 mov BYTE [Flag], 10h @@ -376,7 +376,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Exclusive OR operand r and accumulator +; * Exclusive OR operand s and accumulator ; ****************************************** %MACRO __XORs 2 mov al, %1 @@ -389,7 +389,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Logical OR of operand %1 and accumulator +; * Logical OR of operand s and accumulator ; ******************************************* %MACRO __ORs 2 mov al, %1 @@ -402,7 +402,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Compare operand %1 with accumulator +; * Compare operand s with accumulator ; ************************************** %MACRO __CPs 2 mov BYTE [Flag], 2 @@ -444,7 +444,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Jump relative to PC+e if condition %1 is true +; * Jump relative to PC+e if condition cc is true ; ************************************************* %MACRO __JRccn 2 test BYTE [Flag], %2 @@ -458,7 +458,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Call subroutine at location nn if condition CC is true +; * Call subroutine at location nn if condition cc is true ; ********************************************************** %MACRO __CALLccnn 2 test BYTE [Flag], %2 @@ -478,7 +478,7 @@ _NOLIST: jmp TLF %ENDMACRO -; * Return from subroutine if condition %1 is true +; * Return from subroutine if condition cc is true ; ************************************************** %MACRO __RETcc 2 test BYTE [Flag], %2 @@ -577,7 +577,7 @@ _INCDE: __INCss WORD [rE] _INCHL: __INCss WORD [rL] _INCSP: __INCss DWORD [rSPx] -; * INC %1 - (04,0C,14,1C,24,2C,34,3C) - 4/11 Clk - Increment operand %1 +; * INC r - (04,0C,14,1C,24,2C,34,3C) - 4/11 Clk - Increment operand r ; ********************************************************************** GLOBAL _INCB, _INCC, _INCD, _INCE, _INCH, _INCL, _INC_HL, _INCA _INCB: __INCr BYTE [rB], 4 @@ -606,7 +606,7 @@ INCHL: and ah, 11010000b jmp TLF _INCA: __INCr BYTE [rAcc], 4 -; * DEC s - (05,0D,15,1D,25,2D,35,3D) - 4/11 Clk - Decrement operand s +; * DEC r - (05,0D,15,1D,25,2D,35,3D) - 4/11 Clk - Decrement operand r ; ********************************************************************** GLOBAL _DECB, _DECC, _DECD, _DECE, _DECH, _DECL, _DEC_HL, _DECA _DECB: __DECr BYTE [rB], 4 @@ -636,8 +636,8 @@ DECHL: and ah, 11010000b jmp TLF _DECA: __DECr BYTE [rAcc], 4 -; * LD %1, n - (06,0E,16,1E,26,2E,3E) n - 7 Clk - Load register %1 with value n -; ********************************************************* +; * LD r, n - (06,0E,16,1E,26,2E,3E) n - 7 Clk - Load register r with value n +; ***************************************************************************** GLOBAL _LDBN, _LDCN, _LDDN, _LDEN, _LDHN, _LDLN, _LDAN _LDBN: __LDrn BYTE [rB] _LDCN: __LDrn BYTE [rC] @@ -920,7 +920,7 @@ _CCF: add BYTE [TClock], 4 jmp TLF -; * LD B, %1 - (40,41,42,43,44,45,46,47) - 4/7 Clk - Load register B with operand %1 +; * LD B, r - (40,41,42,43,44,45,46,47) - 4/7 Clk - Load register B with operand r ; ********************************************************************************** GLOBAL _LDBB, _LDBC, _LDBD, _LDBE, _LDBH, _LDBL, _LDB_HL, _LDBA _LDBB: __LDrr BYTE [rB], BYTE [rB], 4 @@ -932,7 +932,7 @@ _LDBL: __LDrr BYTE [rB], BYTE [rL], 4 _LDB_HL:__LDr_HL BYTE [rB] _LDBA: __LDrr BYTE [rB], BYTE [rAcc], 4 -; * LD C, %1 - (48,49,4A,4B,4C,4D,4E,4F) - 4/7 Clk - Load register C with operand %1 +; * LD C, r - (48,49,4A,4B,4C,4D,4E,4F) - 4/7 Clk - Load register C with operand r ; ********************************************************************************** GLOBAL _LDCB, _LDCC, _LDCD, _LDCE, _LDCH, _LDCL, _LDC_HL, _LDCA _LDCB: __LDrr BYTE [rC], BYTE [rB], 4 @@ -944,7 +944,7 @@ _LDCL: __LDrr BYTE [rC], BYTE [rL], 4 _LDC_HL:__LDr_HL BYTE [rC] _LDCA: __LDrr BYTE [rC], BYTE [rAcc], 4 -; * LD D, %1 - (50,51,52,53,54,55,56,57) - 4/7 Clk - Load register D with operand %1 +; * LD D, r - (50,51,52,53,54,55,56,57) - 4/7 Clk - Load register D with operand r ; ********************************************************************************** GLOBAL _LDDB, _LDDC, _LDDD, _LDDE, _LDDH, _LDDL, _LDD_HL, _LDDA _LDDB: __LDrr BYTE [rD], BYTE [rB], 4 @@ -956,7 +956,7 @@ _LDDL: __LDrr BYTE [rD], BYTE [rL], 4 _LDD_HL:__LDr_HL BYTE [rD] _LDDA: __LDrr BYTE [rD], BYTE [rAcc], 4 -; * LD E, %1 - (58,59,5A,5B,5C,5D,5E,5F) - 4/7 Clk - Load register E with operand %1 +; * LD E, r - (58,59,5A,5B,5C,5D,5E,5F) - 4/7 Clk - Load register E with operand r ; ********************************************************************************** GLOBAL _LDEB, _LDEC, _LDED, _LDEE, _LDEH, _LDEL, _LDE_HL, _LDEA _LDEB: __LDrr BYTE [rE], BYTE [rB], 4 @@ -968,7 +968,7 @@ _LDEL: __LDrr BYTE [rE], BYTE [rL], 4 _LDE_HL:__LDr_HL BYTE [rE] _LDEA: __LDrr BYTE [rE], BYTE [rAcc], 4 -; * LD H, %1 - (60,62,63,64,65,66,67) - 4/7 Clk - Load register H with operand %1 +; * LD H, r - (60,62,63,64,65,66,67) - 4/7 Clk - Load register H with operand r ; ******************************************************************************* GLOBAL _LDHB, _LDHC, _LDHD, _LDHE, _LDHH, _LDHL, _LDH_HL, _LDHA _LDHB: __LDrr BYTE [rH], BYTE [rB], 4 @@ -980,7 +980,7 @@ _LDHL: __LDrr BYTE [rH], BYTE [rL], 4 _LDH_HL:__LDr_HL BYTE [rH] _LDHA: __LDrr BYTE [rH], BYTE [rAcc], 4 -; * LD L, %1 - (68,69,6A,6B,6C,6D,6E,6F) - 4/7 Clk - Load register L with operand %1 +; * LD L, r - (68,69,6A,6B,6C,6D,6E,6F) - 4/7 Clk - Load register L with operand r ; ********************************************************************************** GLOBAL _LDLB, _LDLC, _LDLD, _LDLE, _LDLH, _LDLL, _LDL_HL, _LDLA _LDLB: __LDrr BYTE [rL], BYTE [rB], 4 @@ -992,7 +992,7 @@ _LDLL: __LDrr BYTE [rL], BYTE [rL], 4 _LDL_HL:__LDr_HL BYTE [rL] _LDLA: __LDrr BYTE [rL], BYTE [rAcc], 4 -; * LD (HL), %1 - (70,71,72,73,74,75,77) - 7 Clk - Load location (HL) with register %1 +; * LD (HL), r - (70,71,72,73,74,75,77) - 7 Clk - Load location (HL) with register r ; ************************************************************************************ GLOBAL _LD_HL_B, _LD_HL_C, _LD_HL_D, _LD_HL_E, _LD_HL_H, _LD_HL_L, _LD_HL_A _LD_HL_B:__LD_HL_r BYTE [rB] @@ -1011,7 +1011,7 @@ _HALT: add BYTE [TClock], 4 jmp TLF -; * LD A, %1 - (78,79,7A,7B,7C,7D,7E,7F) - 4/7 Clk - Load register A with operand %1 +; * LD A, r - (78,79,7A,7B,7C,7D,7E,7F) - 4/7 Clk - Load register A with operand r ; ********************************************************************************** GLOBAL _LDAB, _LDAC, _LDAD, _LDAE, _LDAH, _LDAL, _LDA_HL, _LDAA _LDAB: __LDrr BYTE [rAcc], BYTE [rB], 4 @@ -1377,7 +1377,7 @@ _FD: ; * Macros ; *************************************************************************************** -; * Rotate operand %1 left circular +; * Rotate operand m left circular ; ********************************** %MACRO __RLCr 3 rol %1, 1 @@ -1392,7 +1392,7 @@ _FD: jmp TLF %ENDMACRO -; * Rotate operand %1 right circular +; * Rotate operand m right circular ; *********************************** %MACRO __RRCr 3 ror %1, 1 @@ -1439,7 +1439,7 @@ _FD: jmp TLF %ENDMACRO -; * Load output port (C) with register %1 +; * Load output port (C) with register r ; **************************************** %MACRO __OUT_C_r 1 mov al, %1 @@ -1464,7 +1464,7 @@ _FD: jmp TLF %ENDMACRO -; * Load location (I$+d) with register %1 +; * Load location (I$+d) with register r ; **************************************** %MACRO __LDIdr 3 mov al, %2 @@ -1487,7 +1487,7 @@ _FD: jmp TLF %ENDMACRO -; * Set bit %1 of location (HL) +; * Set bit b of location (HL) ; ****************************** %MACRO __SETb_HL 1 movzx esi, WORD [rL] @@ -1503,7 +1503,7 @@ _FD: jmp TLF %ENDMACRO -; * Set bit %1 of location (I$+d) +; * Set bit b of location (I$+d) ; ******************************** %MACRO __SETb_Id 2 movsx esi, BYTE [esi+2] @@ -1513,7 +1513,7 @@ _FD: __SETbr %1, BYTE [esi], 23, 4 %ENDMACRO -; * Reset bit %1 of register r +; * Reset bit b of register r ; ***************************** %MACRO __RESbr 4 and %2, ~%1 @@ -1522,7 +1522,7 @@ _FD: jmp TLF %ENDMACRO -; * Reset bit %1 of location (HL) +; * Reset bit b of location (HL) ; ******************************** %MACRO __RESb_HL 1 movzx esi, WORD [rL] @@ -1538,7 +1538,7 @@ _FD: jmp TLF %ENDMACRO -; * Reset bit %1 of location (I$+d) +; * Reset bit b of location (I$+d) ; ********************************** %MACRO __RESb_Id 2 movsx esi, BYTE [esi+2] @@ -1548,7 +1548,7 @@ _FD: __RESbr %1, BYTE [esi], 23, 4 %ENDMACRO -; * Test bit %1 of register r +; * Test bit b of register r ; **************************** %MACRO __BITbr 4 and BYTE [Flag], 1 @@ -1562,7 +1562,7 @@ _FD: jmp TLF %ENDMACRO -; * Test bit %1 of location (HL) +; * Test bit b of location (HL) ; ******************************* %MACRO __BITb_HL 1 movzx esi, WORD [rL] @@ -1570,7 +1570,7 @@ _FD: __BITbr %1, BYTE [esi], 12, 2 %ENDMACRO -; * Test bit %1 of location (I$+d) +; * Test bit b of location (I$+d) ; ******************************* %MACRO __BITb_Id 2 movsx esi, BYTE [esi+2] @@ -2421,22 +2421,22 @@ _ADCA_IXd: call read_mem __ADCAs [esi], 19 -; SUB IXH - DD 94 - 8 Clk - Subtract IXH from accumulator -; ********************************************************* +; * SUB IXH - DD 94 - 8 Clk - Subtract IXH from accumulator +; *********************************************************** GLOBAL _SUBIXH _SUBIXH: inc DWORD [rPCx] __SUBs BYTE [rIX+1], 8 -; SUB IXL - DD 95 - 8 Clk - Subtract IXL from accumulator -; ********************************************************* +; * SUB IXL - DD 95 - 8 Clk - Subtract IXL from accumulator +; *********************************************************** GLOBAL _SUBIXL _SUBIXL: inc DWORD [rPCx] __SUBs BYTE [rIX], 8 -; SUB (IX+d) - DD 96 d - 19 Clk - Subtract location (IX+d) from accumulator -; *************************************************************************** +; * SUB (IX+d) - DD 96 d - 19 Clk - Subtract location (IX+d) from accumulator +; ***************************************************************************** GLOBAL _SUB_IXd _SUB_IXd: add DWORD [rPCx], 2 @@ -2446,8 +2446,8 @@ _SUB_IXd: call read_mem __SUBs [esi], 19 -; SBC A, (IX+d) - DD 9E d - 19 Clk - Subtract location (IX+d) from accumulator with carry -; ***************************************************************************************** +; * SBC A, (IX+d) - DD 9E d - 19 Clk - Subtract location (IX+d) from accumulator with carry +; ******************************************************************************************* GLOBAL _SBCA_IXd _SBCA_IXd: add DWORD [rPCx], 2 @@ -2594,7 +2594,7 @@ _JP_IX: jmp TLF ; * LD SP, IX - DD F9 - 10 Clk - Load SP with IX -; ********************************************* +; ************************************************ GLOBAL _LDSPIX _LDSPIX: mov eax, DWORD [rIX] @@ -2786,7 +2786,7 @@ _RETN: add BYTE [TClock], 14 jmp TLF -; * BYTE [IM] 0 - ED (46,56,5E) - 8 Clk - Set interrupt mode m +; * IM 0 - ED (46,56,5E) - 8 Clk - Set interrupt mode m ; ******************************************************* GLOBAL _IM0, _IM1, _IM2 _IM0: __IM 0 @@ -3436,22 +3436,22 @@ _ADCA_IYd: call read_mem __ADCAs [esi], 19 -; SUB IYH - FD 94 - 8 Clk - Subtract IYH from accumulator -; ********************************************************* +; * SUB IYH - FD 94 - 8 Clk - Subtract IYH from accumulator +; *********************************************************** GLOBAL _SUBIYH _SUBIYH: inc DWORD [rPCx] __SUBs BYTE [rIY+1], 8 -; SUB IYL - FD 95 - 8 Clk - Subtract IYL from accumulator -; ********************************************************* +; * SUB IYL - FD 95 - 8 Clk - Subtract IYL from accumulator +; *********************************************************** GLOBAL _SUBIYL _SUBIYL: inc DWORD [rPCx] __SUBs BYTE [rIY], 8 -; SUB (IY+d) - FD 96 d - 19 Clk - Subtract location (IY+d) from accumulator -; *************************************************************************** +; * SUB (IY+d) - FD 96 d - 19 Clk - Subtract location (IY+d) from accumulator +; ***************************************************************************** GLOBAL _SUB_IYd _SUB_IYd: add DWORD [rPCx], 2 @@ -3461,8 +3461,8 @@ _SUB_IYd: call read_mem __SUBs [esi], 19 -; SBC A, (IY+d) - FD 9E d - 19 Clk - Subtract location (IY+d) from accumulator with carry -; ***************************************************************************************** +; * SBC A, (IY+d) - FD 9E d - 19 Clk - Subtract location (IY+d) from accumulator with carry +; ******************************************************************************************* GLOBAL _SBCA_IYd _SBCA_IYd: add DWORD [rPCx], 2 @@ -3732,7 +3732,7 @@ _SET7_IYd:__SETb_Id 80h, DWORD [rIY] SECTION .data -; Tabela de opcodes +; Opcode table GLOBAL Opcode Opcode: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3769,7 +3769,7 @@ Opcode: DD _RETP, _POPAF, _JPPN, _DI, _CALLPN, _PUSHAF, _ORN, _RST30 DD _RETM, _LDSPHL, _JPMN, _EI, _CALLMN, _FD, _CPN, _RST38 ; F -; Tabela de opcodes (CB) +; Opcode table (CB) GLOBAL OpcodeCB OpcodeCB: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3806,7 +3806,7 @@ OpcodeCB: DD _SET6B, _SET6C, _SET6D, _SET6E, _SET6H, _SET6L, _SET6_HL, _SET6A DD _SET7B, _SET7C, _SET7D, _SET7E, _SET7H, _SET7L, _SET7_HL, _SET7A ; F -; Tabela de opcodes (DD) +; Opcode table (DD) GLOBAL OpcodeDD OpcodeDD: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3843,7 +3843,7 @@ OpcodeDD: DD _NOP, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP DD _NOP, _LDSPIX, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP ; F -; Tabela de opcodes (DD CB) +; Opcode table (DD CB) GLOBAL OpcodeDDCB OpcodeDDCB: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3880,7 +3880,7 @@ OpcodeDDCB: DD _NIMP3, _NIMP3, _NIMP3, _NIMP3, _NIMP3, _NIMP3, _SET6_IXd,_NIMP3 DD _NIMP3, _NIMP3, _NIMP3, _NIMP3, _NIMP3, _NIMP3, _SET7_IXd,_NIMP3 ; F -; Tabela de opcodes (ED) +; Opcode table (ED) GLOBAL OpcodeED OpcodeED: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3917,7 +3917,7 @@ OpcodeED: DD _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST DD _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST, _NOLIST ; F -; Tabela de opcodes (FD) +; Opcode table (FD) GLOBAL OpcodeFD OpcodeFD: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F @@ -3954,7 +3954,7 @@ OpcodeFD: DD _NOP, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP DD _NOP, _LDSPIY, _NOP, _NOP, _NOP, _NOP, _NOP, _NOP ; F -; Tabela de opcodes (FD CB) +; Opcode table (FD CB) GLOBAL OpcodeFDCB OpcodeFDCB: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F diff --git a/core/data.asm b/core/data.asm index a5a03aa..a3b045e 100644 --- a/core/data.asm +++ b/core/data.asm @@ -96,9 +96,9 @@ NoiseFreq2 RESB 1 ; **** VDP **** GLOBAL VDPStatus, cVDP, VDPLow -VDPStatus RESB 1 ; Status do VDP -cVDP RESB 1 ; Primeira ou segunda escrita na porta BFh -VDPLow RESB 1 ; Valor auxiliar de escrita na porta BFh +VDPStatus RESB 1 +cVDP RESB 1 ; First or second write in BFh port +VDPLow RESB 1 ; Temporary value for BFh port GLOBAL pRAM, VDPR, CRAM, VRAM pRAM RESD 1 ; Pointer for palette or video memory diff --git a/core/data.inc b/core/data.inc index 0d581d8..a09fe9d 100644 --- a/core/data.inc +++ b/core/data.inc @@ -1,19 +1,3 @@ -; Alis, A SEGA Master System emulator -; Copyright (C) 2002-2014 Cidorvan Leite - -; This program is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. - -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. - -; You should have received a copy of the GNU General Public License -; along with this program. If not, see [http://www.gnu.org/licenses/]. - ; **** BANKS **** EXTERN pBank0, pBank1, pBank2, pBank2ROM, battery, RAMSelect diff --git a/core/io.asm b/core/io.asm index 35d4480..118ec95 100644 --- a/core/io.asm +++ b/core/io.asm @@ -22,41 +22,25 @@ SECTION .text -; * Porta para escrita não implementada -; *************************************** +; * Write port not implemented +; ****************************** GLOBAL _NWIMP _NWIMP: - ;movzx eax, al - ;push eax - ;push edx - ;push DWORD [rPC] - ;call ?WriteIOErr@@YAXHHH@Z - ;add esp, 12 ret -; * Porta para leitura não implementada -; *************************************** +; * Read port not implemented +; ***************************** GLOBAL _NRIMP _NRIMP: - ;push edx - ;push DWORD [rPC] - ;call ?ReadIOErr@@YAXHH@Z - ;add esp, 8 ret -; * Nada (R) -; ************ -GLOBAL NadaR -NadaR: +; * Nothing to read +; ******************* +GLOBAL Empty +Empty: mov al, 0FFh ret -; * Nada (W) -; ************ -GLOBAL NadaW -NadaW: - ret - ; * 3E Memory Control (W) ; ************************* GLOBAL MemCtrl @@ -113,7 +97,7 @@ WVDPD: cmp esi, 0 je WVDPD1 inc DWORD [pRAM] - cmp DWORD [pRAM], VRAM + 4000h ; cmp DWORD [pRAM], offset VRAM + 4000h + cmp DWORD [pRAM], VRAM + 4000h jb WVDPD0 sub DWORD [pRAM], 4000h WVDPD0: mov [esi], al @@ -134,38 +118,34 @@ _RVDPS: ; ********************** GLOBAL WVDPA WVDPA: - ; Primeira ou segunda escrita? + ; First or second time? test BYTE [cVDP], 1 jnz WVDPA0 mov BYTE [VDPLow], al jmp WVDPAF - ; BYTE [VRAM] endereço + ; VRAM address WVDPA0: test al, 80h jnz WVDPA1 -; mov bl, al and al, 3Fh mov ah, al mov al, BYTE [VDPLow] movzx eax, ax - add eax, VRAM ; add eax, offset VRAM -; test bl, 40h -; jnz WVDPA00 -; inc eax + add eax, VRAM WVDPA00:mov DWORD [pRAM], eax jmp WVDPAF - ; PALRAM endereço + ; PAL RAM address WVDPA1: test al, 40h jz WVDPA2 mov al, BYTE [VDPLow] and al, 1Fh movzx eax, al - add eax, CRAM ; add eax, offset CRAM + add eax, CRAM mov DWORD [pRAM], eax jmp WVDPAF - ; Registros do VDP + ; VDP registers WVDPA2: and al, 0Fh movzx edx, al mov al, BYTE [VDPLow] @@ -232,9 +212,9 @@ SECTION .data GLOBAL read_io read_io: ; 0/8 1/9 2/A 3/B 4/C 5/D 6/E 7/F - DD NadaR, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP + DD Empty, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP DD _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP ; 0 - DD NadaR, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP + DD Empty, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP DD _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP ; 1 DD _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP DD _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP, _NRIMP ; 2 @@ -292,19 +272,19 @@ write_io: DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP ; A DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, WVDPA, WVDPD, WVDPA ; B - DD NadaW, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP + DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP ; C DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP - DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, NadaW, NadaW ; D + DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP ; D DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP ; E DD YMAR, YMDR, YMCRW, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP - DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, NadaW, NadaW ; F + DD _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP, _NWIMP ; F SECTION .bss -; Portas do joystick +; Joystick ports GLOBAL Joy1, Joy2 Joy1 RESB 1 Joy2 RESB 1 diff --git a/core/psg.asm b/core/psg.asm index a923238..13a6f78 100644 --- a/core/psg.asm +++ b/core/psg.asm @@ -15,18 +15,18 @@ ; along with this program. If not, see [http://www.gnu.org/licenses/]. -FREQUENCE EQU 44160 -BUFFERSIZE EQU FREQUENCE / 60 +FREQUENCY EQU 44160 +BUFFERSIZE EQU FREQUENCY / 60 %INCLUDE "data.inc" SECTION .text -; * Reseta o som -; **************** +; * Reset sound system +; ********************** GLOBAL reset_PSG reset_PSG: - ; Limpa os registradores de som + ; Clear sound registers xor eax, eax mov DWORD [rVol1], eax mov DWORD [rFreq1], eax @@ -35,22 +35,22 @@ reset_PSG: mov DWORD [rFreq4], eax mov DWORD [rLast], eax - ; Inicia ruído + ; Initialize noise mov DWORD [Noise], 1 mov DWORD [FeedBack], 8000h mov BYTE [NoiseFreq2], al - ; Inicia Períodos - mov BYTE [Sinal], al - mov DWORD [Periodo1], FREQUENCE - mov DWORD [Periodo2], FREQUENCE - mov DWORD [Periodo3], FREQUENCE - mov DWORD [Periodo4], eax + ; Initialize periods + mov BYTE [Signal], al + mov DWORD [Period1], FREQUENCY + mov DWORD [Period2], FREQUENCY + mov DWORD [Period3], FREQUENCY + mov DWORD [Period4], eax ret -; * Escreve dados nos registradores de som -; ****************************************** +; * Write in sound registers +; **************************** GLOBAL write_PSG write_PSG: test al, 80h @@ -67,7 +67,7 @@ write_PSG: mov BYTE [rVol1+ebx], al ret - ; Frequência (1º escrita) + ; Frequency (first write) PSGW0: cmp bl, 3 je PSGW01 and al, 0Fh @@ -82,13 +82,13 @@ PSGW0: cmp bl, 3 PSGW00: mov DWORD [rLast], ebx ret - ; Ruído + ; Noise PSGW01: test al, 4 jnz PSGW02 mov DWORD [Noise], 1 - mov DWORD [FeedBack], 08000h ; Periodic DWORD [Noise] + mov DWORD [FeedBack], 08000h ; Periodic noise jmp PSGW03 -PSGW02: mov DWORD [FeedBack], 0F037h ; White DWORD [Noise] +PSGW02: mov DWORD [FeedBack], 0F037h ; White noise PSGW03: and al, 3 cmp al, 3 je PSGW04 @@ -103,7 +103,7 @@ PSGW04: mov BYTE [NoiseFreq2], 1 mov DWORD [rFreq4], eax ret - ; Frequência (2º escrita) + ; Frequency (second write) PSGW1: mov ebx, DWORD [rLast] shl eax, 4 and eax, 3F0h @@ -117,8 +117,8 @@ PSGW1: mov ebx, DWORD [rLast] or DWORD [rFreq4], eax PSGW2: ret -; * Atualiza o buffer -; ********************* +; * Updates buffer +; ****************** GLOBAL make_PSG make_PSG: push ebx @@ -127,80 +127,67 @@ make_PSG: push ebp mov esi, [esp+24] ; Second parameter (stream) - ; Limpa o Buffer + ; Clear buffer mov eax, 80808080h mov ecx, BUFFERSIZE / 4 mov edi, esi rep stosd - ; Gera canal 1 + ; Generates channel 1 mov al, BYTE [rVol1] -; shl al, 1 mov ah, 1 - test BYTE [Sinal], ah + test BYTE [Signal], ah jz MPS01 neg al MPS01: mov ebx, DWORD [rFreq1] movzx ebx, WORD [Frequencia+ebx*2] - cmp ebx, FREQUENCE + cmp ebx, FREQUENCY ja MPS2 - mov edx, DWORD [Periodo1] + mov edx, DWORD [Period1] call square_wave - mov DWORD [Periodo1], edx -; jmp MPS2 -;MPS1: call LineWave -; mov DWORD [Periodo1], FREQUENCE + mov DWORD [Period1], edx - ; Gera canal 2 + ; Generates channel 2 MPS2: mov al, BYTE [rVol2] -; shl al, 1 mov ah, 2 - test BYTE [Sinal], ah + test BYTE [Signal], ah jz MPS02 neg al MPS02: mov ebx, DWORD [rFreq2] movzx ebx, WORD [Frequencia+ebx*2] - cmp ebx, FREQUENCE + cmp ebx, FREQUENCY ja MPS4 - mov edx, DWORD [Periodo2] + mov edx, DWORD [Period2] call square_wave - mov DWORD [Periodo2], edx -; jmp MPS4 -;MPS3: call LineWave -;MPS31: mov DWORD [Periodo2], FREQUENCE + mov DWORD [Period2], edx - ; Gera canal 3 + ; Generates channel 3 MPS4: mov al, BYTE [rVol3] -; shl al, 1 mov ah, 4 - test BYTE [Sinal], ah + test BYTE [Signal], ah jz MPS04 neg al MPS04: mov ebx, DWORD [rFreq3] movzx ebx, WORD [Frequencia+ebx*2] - cmp ebx, FREQUENCE + cmp ebx, FREQUENCY ja MPS6 - mov edx, DWORD [Periodo3] + mov edx, DWORD [Period3] call square_wave - mov DWORD [Periodo3], edx -; jmp MPS6 -;MPS5: call LineWave -;MPS51: mov DWORD [Periodo3], FREQUENCE + mov DWORD [Period3], edx - ; Gera canal 4 + ; Generates channel 4 MPS6: mov ah, BYTE [rVol4] shl ah, 1 mov ebx, DWORD [rFreq4] -; shr ebx, 1 movzx ebx, WORD [Frequencia+ebx*2] - cmp ebx, FREQUENCE + cmp ebx, FREQUENCY ja MPS66 mov ecx, BUFFERSIZE - mov edx, DWORD [Periodo4] + mov edx, DWORD [Period4] mov ebp, DWORD [FeedBack] mov edi, esi call WPNoise - mov DWORD [Periodo4], edx + mov DWORD [Period4], edx MPS66: pop ebp pop edi @@ -208,27 +195,8 @@ MPS66: pop ebp pop ebx ret -; * Gera uma linha na altura do volume -; ************************************** -;GLOBAL LineWave -;LineWave: -; mov ecx, BUFFERSIZE / 4 -; mov edi, SoundBuffer ; ; mov edi, offset SoundBuffer -; mov bl, al -; shl eax, 8 -; mov al, bl -; shl eax, 8 -; mov al, bl -; shl eax, 8 -; mov al, bl -;LW0: add [edi], eax -; add edi, 4 -; dec ecx -; jnz LW0 -; ret - -; * Gera uma onda quadrada -; ************************** +; * Generates a squera wave +; *************************** GLOBAL square_wave square_wave: mov ecx, BUFFERSIZE @@ -244,14 +212,14 @@ SW0: jecxz SW1 jg SW0 neg al - xor BYTE [Sinal], ah - add edx, FREQUENCE + xor BYTE [Signal], ah + add edx, FREQUENCY jmp SW0 SW1: ret -; * Gera ruído branco ou periódico -; ********************************** +; * Generates a white or periodic noise +; *************************************** GLOBAL WPNoise WPNoise: test DWORD [Noise], 1 @@ -262,7 +230,7 @@ WPN0: mov al, ah xor DWORD [Noise], ebp WPN1: shr DWORD [Noise], 1 - add edx, FREQUENCE + add edx, FREQUENCY WPN2: jecxz WPN3 add [edi], al inc edi @@ -276,7 +244,7 @@ WPN3: ret SECTION .data -; Tabela de frequências +; Frequency table GLOBAL Frequencia Frequencia: DW 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh, 0F424h, 0C350h, 0A2C2h, 08B82h, 07A12h, 06C81h, 061A8h @@ -378,9 +346,9 @@ Frequencia: SECTION .bss ; Channels period -GLOBAL Sinal, Periodo1, Periodo2, Periodo3, Periodo4 -Sinal RESB 1 -Periodo1 RESD 1 -Periodo2 RESD 1 -Periodo3 RESD 1 -Periodo4 RESD 1 +GLOBAL Signal, Period1, Period2, Period3, Period4 +Signal RESB 1 +Period1 RESD 1 +Period2 RESD 1 +Period3 RESD 1 +Period4 RESD 1 diff --git a/core/vdp.asm b/core/vdp.asm index 8e0a9f8..ccf9c6e 100644 --- a/core/vdp.asm +++ b/core/vdp.asm @@ -21,20 +21,20 @@ SECTION .text -; * Reseta VDP -; ************** +; * Reset VDP +; ************* GLOBAL reset_VDP reset_VDP: push edi - ; Inicia VDP Control + ; Initialize VDP controls xor eax, eax mov BYTE [cVDP], al mov BYTE [VDPLow], al mov BYTE [VDPStatus], al mov BYTE [LineInt], al - ; Limpa registradores, palheta de cores e memória de vídeo + ; Clear registers, palette and video memory mov ecx, (4+16+32+4000h)/4 mov edi, pRAM rep stosd @@ -42,8 +42,8 @@ reset_VDP: pop edi ret -; * Gera um frame -; ***************** +; * Render a frame +; ****************** GLOBAL scan_frame scan_frame: push ebx @@ -51,13 +51,13 @@ scan_frame: push edi push ebp - ; Limpa o frame + ; Clear buffer xor eax, eax mov ecx, 256 * 192 - mov edi, [esp+20] ; Param buffer + mov edi, [esp+20] ; Param buffer rep stosd - ; Começa um novo frame + ; Start a new frame mov DWORD [ScanLine], 0 mov al, BYTE [VDPR+10] ; Line Counter cmp al, 192 @@ -65,10 +65,10 @@ scan_frame: dec al SF00: mov BYTE [VDPCounter], al - ; Processa cada scanline + ; Executes each scanline SF0: call TraceLine - ; Renderiza este scanline + ; Renders last scanline cmp DWORD [ScanLine], 192 jae SF1 test BYTE [VDPR+1], 40h @@ -79,42 +79,41 @@ SF0: call TraceLine je SF1 call render_background_layer2 - ; Linhas 0-192 + ; Lines 0-192 SF1: cmp DWORD [ScanLine], 192 ja SF5 - ; Seta bit 7 do VDP Status se a linha for igual a 192 + ; Frame Interrupt on line 192 jne SF2 or BYTE [VDPStatus], 80h ; Frame Interrupt pendente - ; Checa Line Interrupt + ; Checks Line Interrupt SF2: cmp BYTE [VDPCounter], 0 jne SF3 - mov al, BYTE [VDPR+10] ; Line Counter + mov al, BYTE [VDPR+10] ; Line Counter mov BYTE [VDPCounter], al - mov BYTE [LineInt], 1 ; Line Interrupt pendente + mov BYTE [LineInt], 1 ; Line Interrupt pending jmp SF4 - ; Decrementa o contador do Line Interrupt SF3: dec BYTE [VDPCounter] - ; Se a interrupção está pendente e abilitada, gere-a + ; Trigger Line Interruption cmp BYTE [LineInt], 0 je SF6 -SF4: test BYTE [VDPR+0], 10h ; Line Interrupt +SF4: test BYTE [VDPR+0], 10h ; Line Interrupt jz SF6 call int_Z80 jmp SF6 - ; Linhas 193-261 -SF5: mov al, BYTE [VDPR+10] ; Line Counter + ; Lines 193-261 +SF5: mov al, BYTE [VDPR+10] ; Line Counter mov BYTE [VDPCounter], al cmp DWORD [ScanLine], 224 jae SF6 test BYTE [VDPStatus], 80h ; Frame Interrupt pendente jz SF6 - test BYTE [VDPR+1], 20h ; Frame Interrupt + test BYTE [VDPR+1], 20h ; Frame Interrupt jz SF6 call int_Z80 @@ -129,23 +128,11 @@ SF6: sub BYTE [TClock], 228 pop ebx ret -; * Renderiza uma linha -; *********************** +; * Render one line +; ******************* render_background_layer: mov BYTE [RenderBL2], 0 -; mov eax, DWORD [ScanLine] -; shr eax, 3 -; shl eax, 6 -; mov esi, VRAM -; add esi, eax -; movzx eax, BYTE [VDPR+2] -; shl eax, 10 -; and eax, 3800h -; add eax, 48 -; add esi, eax -; mov scrolly, esi - movzx eax, BYTE [VDPR+9] add eax, DWORD [ScanLine] cmp eax, 224 @@ -163,12 +150,12 @@ RL000: shr eax, 3 mov eax, DWORD [ScanLine] shl eax, 10 - mov edi, [esp+24] ; Param buffer (after one call instruction) + mov edi, [esp+24] ; Param buffer (after one call instruction) add edi, eax mov DWORD [scrollx], 0 - ; Ocuta as duas primeiras linhas + ; Hide first two lines test BYTE [VDPR+0], 40h jz RL00 cmp DWORD [ScanLine], 16 @@ -184,22 +171,15 @@ RL01: movzx ebx, BYTE [VDPR+9] shl ebx, 2 mov ch, 32 -RL0:; cmp ch, 8 -; jne RL_0 -; mov esi, scrolly RL_0: movzx edx, WORD [esi] add esi, 2 - ; Usar palheta do sprite? + ; Sprite palette? mov DWORD [pal], edx and DWORD [pal], 0800h shr DWORD [pal], 7 -; mov DWORD [pal], 0 * -; test byte ptr [esi-1], 8h * -; jz RL_00 * Obsoleto -; mov DWORD [pal], 16 * -RL_00: test BYTE [esi-1], 10h ; Tile na frente do sprite (renderiza depois) +RL_00: test BYTE [esi-1], 10h ; Tile in front layer (renders after) jz RL11 mov BYTE [RenderBL2], 1 mov eax, DWORD [pal] @@ -233,19 +213,19 @@ RL_00: test BYTE [esi-1], 10h ; Tile na frente do sprite (renderiza depois) and edx, 3FFh mov DWORD [scrollx], edx dec ch - jnz RL0 + jnz RL_0 ret RL11: and edx, 1FFh shl edx, 5 mov eax, ebx - test BYTE [esi-1], 4h ; Flip Vertical + test BYTE [esi-1], 4h ; Flip Vertical jz RL12 mov eax, 28 sub eax, ebx RL12: mov ebp, DWORD [VRAM+edx+eax] - test BYTE [esi-1], 2h ; Flip Horizontal + test BYTE [esi-1], 2h ; Flip Horizontal jnz RL22 mov cl, 8 @@ -273,7 +253,7 @@ RL1: mov eax, ebp dec cl jnz RL1 dec ch - jnz RL0 + jnz RL_0 ret RL22: mov cl, 8 @@ -300,11 +280,11 @@ RL3: mov eax, ebp dec cl jnz RL3 dec ch - jnz RL0 + jnz RL_0 ret -; * Renderiza uma linha -; *********************** +; * Render one line in front layer +; ********************************** render_background_layer2: movzx eax, BYTE [VDPR+9] add eax, DWORD [ScanLine] @@ -323,12 +303,12 @@ RBL000: shr eax, 3 mov eax, DWORD [ScanLine] shl eax, 10 - mov edi, [esp+24] ; Param buffer (after one call instruction) + mov edi, [esp+24] ; Param buffer (after one call instruction) add edi, eax mov DWORD [scrollx], 0 - ; Ocuta as duas primeiras linhas + ; Hide first two lines test BYTE [VDPR+0], 40h jz RBL00 cmp DWORD [ScanLine], 16 @@ -344,33 +324,30 @@ RBL01: movzx ebx, BYTE [VDPR+9] shl ebx, 2 mov ch, 32 -RBL0:; cmp ch, 8 -; jne RL_0 -; mov esi, scrolly RBL_0: movzx edx, WORD [esi] add esi, 2 - test BYTE [esi-1], 10h ; Tile na frente do sprite (renderiza depois) + test BYTE [esi-1], 10h ; Tile in front layer (renders now) jnz RBL_00 add DWORD [scrollx], 8*4 and DWORD [scrollx], 3FFh dec ch - jnz RBL0 + jnz RBL_0 ret RBL_00: and edx, 1FFh shl edx, 5 mov eax, ebx - test BYTE [esi-1], 4h ; Flip Vertical + test BYTE [esi-1], 4h ; Flip Vertical jz RBL11 mov eax, 28 sub eax, ebx RBL11: mov DWORD [pal], 0 - test BYTE [esi-1], 8h ; Usar palheta de sprite + test BYTE [esi-1], 8h ; Sprite palette jz RBL12 mov DWORD [pal], 16 RBL12: mov ebp, DWORD [VRAM+edx+eax] - test BYTE [esi-1], 2h ; Flip Horizontal + test BYTE [esi-1], 2h ; Flip Horizontal jnz RBL22 mov cl, 8 @@ -401,7 +378,7 @@ RBL14: add edx, 4 dec cl jnz RBL1 dec ch - jnz RBL0 + jnz RBL_0 ret RBL22: mov cl, 8 @@ -431,11 +408,11 @@ RBL5: add edx, 4 dec cl jnz RBL3 dec ch - jnz RBL0 + jnz RBL_0 ret -; * Renderiza uma linha da camada de sprite -; ******************************************* +; * Render one sprite line +; ************************** render_sprite_layer: xor ecx, ecx mov esi, VRAM + 3F00h @@ -461,7 +438,7 @@ RSL00: mov DWORD [sb], 0 RSL01: mov eax, DWORD [ScanLine] shl eax, 10 - mov edi, [esp+24] ; Param buffer (after one call instruction) + mov edi, [esp+24] ; Param buffer (after one call instruction) add edi, eax mov DWORD [vb], edi @@ -471,8 +448,6 @@ RSL01: mov eax, DWORD [ScanLine] RSL0: mov al, BYTE [sl] mov ah, [esi+ecx] -; cmp ah, 208 -; je RSL2 sub al, ah cmp al, BYTE [s8x] jae RSL1 @@ -516,8 +491,6 @@ RSL4: add edi, 4 RSL1: dec cl jnl RSL0 -; cmp cl, 64 -; jb RSL0 RSL2: ret @@ -537,16 +510,14 @@ palette: SECTION .bss scrollx RESD 1 -;scrolly RESD 1 pal RESD 1 vb RESD 1 sl RESB 1 -;sl2 RESD 1 sb RESD 1 s8x RESB 1 RenderBL2 RESB 1 GLOBAL ScanLine, LineInt, VDPCounter -ScanLine RESD 1 ; Scanline atual -LineInt RESB 1 ; Line Interrupt pendente +ScanLine RESD 1 ; Current scanline +LineInt RESB 1 ; Line Interrupt pending VDPCounter RESB 1 ; Line Interrupt Counter