Fix usage of rIE and rSC constants

This commit is contained in:
mid-kid 2019-05-05 18:14:46 +02:00
parent 40766b9a76
commit 13cfe356d6
13 changed files with 77 additions and 76 deletions

View File

@ -42,6 +42,7 @@ LCD_STAT EQU 1
TIMER EQU 2 TIMER EQU 2
SERIAL EQU 3 SERIAL EQU 3
JOYPAD EQU 4 JOYPAD EQU 4
IE_DEFAULT EQU (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
; OAM attribute flags ; OAM attribute flags
OAM_TILE_BANK EQU 3 OAM_TILE_BANK EQU 3

View File

@ -50,17 +50,17 @@ Gen2ToGen1LinkComms:
call DelayFrames call DelayFrames
xor a xor a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
xor a xor a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
.player_1 .player_1
@ -70,7 +70,7 @@ Gen2ToGen1LinkComms:
call DelayFrames call DelayFrames
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $8 ld a, 1 << SERIAL
ldh [rIE], a ldh [rIE], a
ld hl, wd1f3 ld hl, wd1f3
ld de, wEnemyMonSpecies ld de, wEnemyMonSpecies
@ -90,7 +90,7 @@ Gen2ToGen1LinkComms:
call Serial_ExchangeBytes call Serial_ExchangeBytes
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $1d ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
call Link_CopyRandomNumbers call Link_CopyRandomNumbers
ld hl, wOTPlayerName ld hl, wOTPlayerName
@ -194,17 +194,17 @@ Gen2ToGen2LinkComms:
call DelayFrames call DelayFrames
xor a xor a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
xor a xor a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
.Player1: .Player1:
@ -214,7 +214,7 @@ Gen2ToGen2LinkComms:
call DelayFrames call DelayFrames
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $8 ld a, 1 << SERIAL
ldh [rIE], a ldh [rIE], a
ld hl, wd1f3 ld hl, wd1f3
ld de, wEnemyMonSpecies ld de, wEnemyMonSpecies
@ -243,7 +243,7 @@ Gen2ToGen2LinkComms:
.not_trading .not_trading
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $1d ld a, (1 << JOYPAD) | (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
ld de, MUSIC_NONE ld de, MUSIC_NONE
call PlayMusic call PlayMusic
@ -447,7 +447,7 @@ Gen2ToGen2LinkComms:
xor a xor a
ldh [rIF], a ldh [rIF], a
ldh a, [rIE] ldh a, [rIE]
set 1, a set LCD_STAT, a
ldh [rIE], a ldh [rIE], a
pop af pop af
ldh [rIF], a ldh [rIF], a
@ -1558,9 +1558,9 @@ Function28b22:
xor a xor a
ldh [rSB], a ldh [rSB], a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret
@ -2104,18 +2104,18 @@ WaitForOtherPlayerToExit:
xor a xor a
ldh [rSB], a ldh [rSB], a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld c, 3 ld c, 3
call DelayFrames call DelayFrames
xor a xor a
ldh [rSB], a ldh [rSB], a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, (0 << rSC_ON) | 0 ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 0 ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld c, 3 ld c, 3
call DelayFrames call DelayFrames
@ -2131,7 +2131,7 @@ WaitForOtherPlayerToExit:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $f ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
pop af pop af
ldh [rIF], a ldh [rIF], a
@ -2160,9 +2160,9 @@ SetBitsForTimeCapsuleRequest:
ldh [rSB], a ldh [rSB], a
xor a xor a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, (0 << rSC_ON) | 0 ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 0 ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
xor a ; LINK_TIMECAPSULE - 1 xor a ; LINK_TIMECAPSULE - 1
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
@ -2177,9 +2177,9 @@ WaitForLinkedFriend:
ldh [rSB], a ldh [rSB], a
xor a xor a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, (0 << rSC_ON) | 0 ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 0 ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
@ -2202,9 +2202,9 @@ WaitForLinkedFriend:
ldh [rSB], a ldh [rSB], a
xor a xor a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, (0 << rSC_ON) | 0 ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 0 ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, [wLinkTimeoutFrames] ld a, [wLinkTimeoutFrames]
dec a dec a
@ -2218,9 +2218,9 @@ WaitForLinkedFriend:
.not_done .not_done
ld a, $1 ld a, $1
ldh [rSB], a ldh [rSB], a
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
call DelayFrame call DelayFrame
jr .loop jr .loop

View File

@ -434,7 +434,7 @@ Function104bd0:
xor a xor a
ldh [rIF], a ldh [rIF], a
ldh a, [rIE] ldh a, [rIE]
or $1 or 1 << VBLANK
ldh [rIE], a ldh [rIE], a
ei ei
call DelayFrame call DelayFrame
@ -559,7 +559,7 @@ Function104d1c:
xor a xor a
ldh [rIF], a ldh [rIF], a
ldh a, [rIE] ldh a, [rIE]
or $1 or 1 << VBLANK
ldh [rIE], a ldh [rIE], a
ei ei
call DelayFrame call DelayFrame
@ -600,7 +600,7 @@ Function104d56:
Function104d5e: Function104d5e:
call Function104d74 call Function104d74
ld a, $4 ld a, 1 << TIMER
ldh [rIE], a ldh [rIE], a
xor a xor a
ldh [rIF], a ldh [rIF], a

View File

@ -56,7 +56,7 @@ PrintDexEntry:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $9 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
call Printer_StartTransmission call Printer_StartTransmission
@ -140,13 +140,13 @@ PrintPCBox:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %1001 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
ld hl, hVBlank ld hl, hVBlank
ld a, [hl] ld a, [hl]
push af push af
ld [hl], %0100 ld [hl], 4
xor a xor a
ldh [hBGMapMode], a ldh [hBGMapMode], a
@ -219,7 +219,7 @@ PrintUnownStamp:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, $9 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
ld hl, hVBlank ld hl, hVBlank
ld a, [hl] ld a, [hl]
@ -284,7 +284,7 @@ PrintMail:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %1001 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
xor a xor a
@ -326,7 +326,7 @@ PrintPartymon:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %1001 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
xor a xor a
@ -390,7 +390,7 @@ _PrintDiploma:
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %1001 ld a, (1 << SERIAL) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
ld hl, hVBlank ld hl, hVBlank
@ -458,9 +458,9 @@ CheckCancelPrint:
ld [wPrinterOpcode], a ld [wPrinterOpcode], a
ld a, $88 ld a, $88
ldh [rSB], a ldh [rSB], a
ld a, $1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, $81 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
.loop2 .loop2
ld a, [wPrinterOpcode] ld a, [wPrinterOpcode]

View File

@ -279,9 +279,9 @@ Printer_WaitHandshake:
ld [wPrinterOpcode], a ld [wPrinterOpcode], a
ld a, $88 ld a, $88
ldh [rSB], a ldh [rSB], a
ld a, $1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, $81 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret
@ -622,9 +622,9 @@ Printer_Send0x08:
Printer_SerialSend: Printer_SerialSend:
ldh [rSB], a ldh [rSB], a
ld a, $1 ; switch to internal clock ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, $81 ; start transfer ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret

View File

@ -32,11 +32,11 @@ AskSerial::
ldh [rSB], a ldh [rSB], a
; switch to internal clock ; switch to internal clock
ld a, %00000001 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
; start transfer ; start transfer
ld a, %10000001 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret

View File

@ -6,7 +6,7 @@ Reset::
call ClearPalettes call ClearPalettes
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, 1 ; VBlank int ld a, 1 << VBLANK
ldh [rIE], a ldh [rIE], a
ei ei
@ -154,7 +154,7 @@ Init::
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %1111 ; VBlank, LCDStat, Timer, Serial interrupts ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
ei ei

View File

@ -46,7 +46,7 @@ DisableLCD::
ld b, a ld b, a
; Disable VBlank ; Disable VBlank
res 0, a ; vblank res VBLANK, a
ldh [rIE], a ldh [rIE], a
.wait .wait

View File

@ -28,9 +28,9 @@ Serial::
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr z, .player2 jr z, .player2
ld a, 0 << rSC_ON ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, 1 << rSC_ON ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
jr .player2 jr .player2
@ -65,9 +65,9 @@ Serial::
bit 7, a bit 7, a
jr nz, .wait_bit_7 jr nz, .wait_bit_7
ld a, 0 << rSC_ON ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, 1 << rSC_ON ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
jr .player2 jr .player2
@ -130,9 +130,9 @@ Serial_ExchangeByte::
ldh a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr nz, .not_player_2 jr nz, .not_player_2
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
.not_player_2 .not_player_2
.loop2 .loop2
@ -352,9 +352,9 @@ LinkTransfer::
ldh a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
jr nz, .player_1 jr nz, .player_1
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
.player_1 .player_1
@ -382,9 +382,9 @@ LinkDataReceived::
ldh a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK cp USING_INTERNAL_CLOCK
ret nz ret nz
ld a, (0 << rSC_ON) | 1 ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, (1 << rSC_ON) | 1 ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret
@ -396,8 +396,8 @@ Unreferenced_Function919::
ldh [rSB], a ldh [rSB], a
xor a xor a
ldh [hSerialReceive], a ldh [hSerialReceive], a
ld a, 0 << rSC_ON ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, 1 << rSC_ON ld a, (1 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ret ret

View File

@ -196,13 +196,13 @@ VBlank1::
xor a xor a
ldh [rIF], a ldh [rIF], a
; enable lcd stat ; enable lcd stat
ld a, %10 ; lcd stat ld a, 1 << LCD_STAT
ldh [rIE], a ldh [rIE], a
; rerequest serial int if applicable (still disabled) ; rerequest serial int if applicable (still disabled)
; request lcd stat ; request lcd stat
ld a, b ld a, b
and %1000 ; serial and 1 << SERIAL
or %10 ; lcd stat or 1 << LCD_STAT
ldh [rIF], a ldh [rIF], a
ei ei
@ -220,7 +220,7 @@ VBlank1::
xor a xor a
ldh [rIF], a ldh [rIF], a
; enable ints besides joypad ; enable ints besides joypad
ld a, %1111 ; serial timer lcdstat vblank ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
; rerequest ints ; rerequest ints
ld a, b ld a, b
@ -279,7 +279,7 @@ VBlank3::
push af push af
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %10 ; lcd stat ld a, 1 << LCD_STAT
ldh [rIE], a ldh [rIE], a
ldh [rIF], a ldh [rIF], a
@ -302,7 +302,7 @@ VBlank3::
xor a xor a
ldh [rIF], a ldh [rIF], a
; enable ints besides joypad ; enable ints besides joypad
ld a, %1111 ; serial timer lcdstat vblank ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
; request ints ; request ints
ld a, b ld a, b
@ -368,7 +368,7 @@ VBlank5::
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, %10 ; lcd stat ld a, 1 << LCD_STAT
ldh [rIE], a ldh [rIE], a
; request lcd stat ; request lcd stat
ldh [rIF], a ldh [rIF], a
@ -384,7 +384,7 @@ VBlank5::
xor a xor a
ldh [rIF], a ldh [rIF], a
; enable ints besides joypad ; enable ints besides joypad
ld a, %1111 ; serial timer lcdstat vblank ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
ret ret

View File

@ -605,7 +605,7 @@ Function11032c:
Function110393: Function110393:
ld c, LOW(rIE) ld c, LOW(rIE)
ldh a, [c] ldh a, [c]
or $c or (1 << SERIAL) | (1 << TIMER)
ldh [c], a ldh [c], a
ret ret
@ -4101,9 +4101,9 @@ Function111b21:
Function111b2e: Function111b2e:
ld hl, $c822 ld hl, $c822
set 1, [hl] set 1, [hl]
ld a, $3 ld a, (0 << rSC_ON) | (1 << rSC_CGB) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
ld a, $83 ld a, (1 << rSC_ON) | (1 << rSC_CGB) | (1 << rSC_CLOCK)
ldh [rSC], a ldh [rSC], a
Function111b3b: Function111b3b:
@ -4684,7 +4684,7 @@ Function111f07:
ret ret
.asm_111f17 .asm_111f17
ldh a, [rSC] ldh a, [rSC]
and $80 and 1 << rSC_ON
jr nz, .asm_111f17 jr nz, .asm_111f17
di di
ld a, [$c81e] ld a, [$c81e]

View File

@ -79,7 +79,7 @@ EnableMobile:
call DoubleSpeed call DoubleSpeed
xor a xor a
ldh [rIF], a ldh [rIF], a
ld a, 1 << VBLANK | 1 << LCD_STAT | 1 << TIMER | 1 << SERIAL ld a, IE_DEFAULT
ldh [rIE], a ldh [rIE], a
xor a xor a
ldh [hMapAnims], a ldh [hMapAnims], a
@ -162,7 +162,7 @@ Function1000fa:
xor a xor a
ldh [rIF], a ldh [rIF], a
ldh a, [rIE] ldh a, [rIE]
and $13 and $1f ^ (1 << SERIAL | 1 << TIMER)
ldh [rIE], a ldh [rIE], a
xor a xor a
ldh [hMobileReceive], a ldh [hMobileReceive], a

View File

@ -469,7 +469,7 @@ BattleTowerRoomMenu_InitRAM:
ld a, [hl] ld a, [hl]
ld [wcd7f], a ld [wcd7f], a
set 1, [hl] set 1, [hl]
ld a, $f ld a, (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
ldh [rIE], a ldh [rIE], a
ld a, $1 ld a, $1
ldh [hMobileReceive], a ldh [hMobileReceive], a