Skip to content

Commit

Permalink
Fix code for new release of rgbds
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Aug 18, 2024
1 parent 9f6bf1c commit f9ac09a
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 126 deletions.
242 changes: 121 additions & 121 deletions src/constants.asm
Original file line number Diff line number Diff line change
@@ -1,167 +1,167 @@
CGB_A_INIT EQU $11 ; Accumulator starting value on a Gameboy Color
DEF CGB_A_INIT EQU $11 ; Accumulator starting value on a Gameboy Color

; Sound control
DISABLE_CHANNELS_REGISTERS EQU $FF26
DEF DISABLE_CHANNELS_REGISTERS EQU $FF26

; Sound Channel 1
CHANNEL1_SWEEP EQU $FF10
CHANNEL1_LENGTH EQU $FF11
CHANNEL1_VOLUME EQU $FF12
CHANNEL1_LOW_FREQ EQU $FF13
CHANNEL1_HIGH_FREQ EQU $FF14
DEF CHANNEL1_SWEEP EQU $FF10
DEF CHANNEL1_LENGTH EQU $FF11
DEF CHANNEL1_VOLUME EQU $FF12
DEF CHANNEL1_LOW_FREQ EQU $FF13
DEF CHANNEL1_HIGH_FREQ EQU $FF14

; Sound Channel 2
CHANNEL2_LENGTH EQU $FF16
CHANNEL2_VOLUME EQU $FF17
CHANNEL2_LOW_FREQ EQU $FF18
CHANNEL2_HIGH_FREQ EQU $FF19
DEF CHANNEL2_LENGTH EQU $FF16
DEF CHANNEL2_VOLUME EQU $FF17
DEF CHANNEL2_LOW_FREQ EQU $FF18
DEF CHANNEL2_HIGH_FREQ EQU $FF19

; Sound channel 3
CHANNEL3_ON_OFF EQU $FF1A
CHANNEL3_LENGTH EQU $FF1B
CHANNEL3_OUTPUT EQU $FF1C
CHANNEL3_LOW_FREQ EQU $FF1D
CHANNEL3_HIGH_FREQ EQU $FF1E
WPRAM EQU $FF30
DEF CHANNEL3_ON_OFF EQU $FF1A
DEF CHANNEL3_LENGTH EQU $FF1B
DEF CHANNEL3_OUTPUT EQU $FF1C
DEF CHANNEL3_LOW_FREQ EQU $FF1D
DEF CHANNEL3_HIGH_FREQ EQU $FF1E
DEF WPRAM EQU $FF30

; Sound channel 4
CHANNEL4_LENGTH EQU $FF20
CHANNEL4_VOLUME EQU $FF21
CHANNEL4_POLY EQU $FF22
CHANNEL4_RESTART EQU $FF23
DEF CHANNEL4_LENGTH EQU $FF20
DEF CHANNEL4_VOLUME EQU $FF21
DEF CHANNEL4_POLY EQU $FF22
DEF CHANNEL4_RESTART EQU $FF23

; LCD
LCD_CONTROL EQU $FF40
STAT_CONTROL EQU $FF41
LCD_BASE_CONTROL EQU %11110111
SCROLL_X EQU $FF43
SCROLL_Y EQU $FF42
LY EQU $FF44
LYC EQU $FF45
WX EQU $FF4B
WY EQU $FF4A
DEF LCD_CONTROL EQU $FF40
DEF STAT_CONTROL EQU $FF41
DEF LCD_BASE_CONTROL EQU %11110111
DEF SCROLL_X EQU $FF43
DEF SCROLL_Y EQU $FF42
DEF LY EQU $FF44
DEF LYC EQU $FF45
DEF WX EQU $FF4B
DEF WY EQU $FF4A

; VRAM
VRAM_START EQU $8000
VRAM_BG_START EQU $9800
DEF VRAM_START EQU $8000
DEF VRAM_BG_START EQU $9800

; Characters
TM_CHARACTER EQU $88
DEF TM_CHARACTER EQU $88

; Joypad
JOYPAD_REGISTER EQU $FF00
DEF JOYPAD_REGISTER EQU $FF00

; Interrupts
INTERRUPT_REQUEST EQU $FF0F
INTERRUPT_ENABLED EQU $FFFF
NO_INTERRUPT EQU 0
VBLANK_INTERRUPT EQU (1 << 0)
LCD_STAT_INTERRUPT EQU (1 << 1)
TIMER_INTERRUPT EQU (1 << 2)
SERIAL_INTERRUPT EQU (1 << 3)
JOYPAD_INTERRUPT EQU (1 << 4)
DEF INTERRUPT_REQUEST EQU $FF0F
DEF INTERRUPT_ENABLED EQU $FFFF
DEF NO_INTERRUPT EQU 0
DEF VBLANK_INTERRUPT EQU (1 << 0)
DEF LCD_STAT_INTERRUPT EQU (1 << 1)
DEF TIMER_INTERRUPT EQU (1 << 2)
DEF SERIAL_INTERRUPT EQU (1 << 3)
DEF JOYPAD_INTERRUPT EQU (1 << 4)

; Misc registers
DIV_REGISTER EQU $FF04
PALETTE_REGISTER EQU $FF47
DEF DIV_REGISTER EQU $FF04
DEF PALETTE_REGISTER EQU $FF47

; Game registers
FRAME_COUNTER EQU $C000
HARDWARE_TYPE EQU $C001
RANDOM_REGISTER EQU $C002
PLAYER1_STRUCT EQU $C003
BOSS_DEATH_COUNTER EQU $C005
BOSS_STRUCT EQU $C006
SHOOT_COOLDOWN EQU $C018
NB_SHOOTS EQU $C019
SHOOTS_PTR EQU $C01A
MUSIC_TIMER EQU $C030
MUSIC_PTR_H EQU $C031
MUSIC_PTR_L EQU $C032
MUSIC_START_PTR_H EQU $C033
MUSIC_START_PTR_L EQU $C034
MUSIC_2_TIMER EQU $C035
MUSIC_2_PTR_H EQU $C036
MUSIC_2_PTR_L EQU $C037
MUSIC_2_START_PTR_H EQU $C038
MUSIC_2_START_PTR_L EQU $C039
INTRO_COUNTER EQU $C03A
CREDITS_CURRENT_LINE EQU $C03B
CREDITS_LAST_ADDR_H EQU $C03C
CREDITS_LAST_ADDR_L EQU $C03D
CREDITS_LINE_POS EQU $C03E
CREDITS_SLIDING EQU $C03F
CREDITS_LINES EQU $C040
SCORE_REGISTER EQU $C041
NB_OBSTACLES EQU $C04F
OBSTACLES_ADDR EQU $C050
BOSS_STATUS EQU $C190
DISABLE_BOSS EQU $C191
BOSS_NEXT_ATTACK EQU $C192
ASTEROID_SPAWN_IN EQU $C193
ASTEROID_MAX_SPEED_Y EQU $C194
ASTEROID_MAX_SPEED_X EQU $C195
ASTEROID_NEXT_INC EQU $C196
BANK_POINTER EQU $C200
BOSS_ADDR EQU $C880
DEF FRAME_COUNTER EQU $C000
DEF HARDWARE_TYPE EQU $C001
DEF RANDOM_REGISTER EQU $C002
DEF PLAYER1_STRUCT EQU $C003
DEF BOSS_DEATH_COUNTER EQU $C005
DEF BOSS_STRUCT EQU $C006
DEF SHOOT_COOLDOWN EQU $C018
DEF NB_SHOOTS EQU $C019
DEF SHOOTS_PTR EQU $C01A
DEF MUSIC_TIMER EQU $C030
DEF MUSIC_PTR_H EQU $C031
DEF MUSIC_PTR_L EQU $C032
DEF MUSIC_START_PTR_H EQU $C033
DEF MUSIC_START_PTR_L EQU $C034
DEF MUSIC_2_TIMER EQU $C035
DEF MUSIC_2_PTR_H EQU $C036
DEF MUSIC_2_PTR_L EQU $C037
DEF MUSIC_2_START_PTR_H EQU $C038
DEF MUSIC_2_START_PTR_L EQU $C039
DEF INTRO_COUNTER EQU $C03A
DEF CREDITS_CURRENT_LINE EQU $C03B
DEF CREDITS_LAST_ADDR_H EQU $C03C
DEF CREDITS_LAST_ADDR_L EQU $C03D
DEF CREDITS_LINE_POS EQU $C03E
DEF CREDITS_SLIDING EQU $C03F
DEF CREDITS_LINES EQU $C040
DEF SCORE_REGISTER EQU $C041
DEF NB_OBSTACLES EQU $C04F
DEF OBSTACLES_ADDR EQU $C050
DEF BOSS_STATUS EQU $C190
DEF DISABLE_BOSS EQU $C191
DEF BOSS_NEXT_ATTACK EQU $C192
DEF ASTEROID_SPAWN_IN EQU $C193
DEF ASTEROID_MAX_SPEED_Y EQU $C194
DEF ASTEROID_MAX_SPEED_X EQU $C195
DEF ASTEROID_NEXT_INC EQU $C196
DEF BANK_POINTER EQU $C200
DEF BOSS_ADDR EQU $C880

; Game constants
NB_SHOOTS_MAX EQU 10
NB_PLAYERS EQU 2
NB_LASERS_MAX EQU 10
NB_ASTEROIDS_MAX EQU 14
BASE_SHOOT_COOLDOWN EQU 15
BOSS_SIZE_X EQU $20
BOSS_SIZE_Y EQU $10
PLAYER_SIZE_X EQU $10
PLAYER_SIZE_Y EQU $10
SPACESHIP_PALETTE EQU %00100111
ENNEMIES_PALETTE EQU %11000111
DEF NB_SHOOTS_MAX EQU 10
DEF NB_PLAYERS EQU 2
DEF NB_LASERS_MAX EQU 10
DEF NB_ASTEROIDS_MAX EQU 14
DEF BASE_SHOOT_COOLDOWN EQU 15
DEF BOSS_SIZE_X EQU $20
DEF BOSS_SIZE_Y EQU $10
DEF PLAYER_SIZE_X EQU $10
DEF PLAYER_SIZE_Y EQU $10
DEF SPACESHIP_PALETTE EQU %00100111
DEF ENNEMIES_PALETTE EQU %11000111

; DMG Palette
BGP EQU $FF47
OBP0 EQU $FF48
OBP1 EQU $FF49
DEF BGP EQU $FF47
DEF OBP0 EQU $FF48
DEF OBP1 EQU $FF49

; GBC Palette
BGPI EQU $FF68
BGPD EQU $FF69
OBPI EQU $FF6A
OBPB EQU $FF6B
DEF BGPI EQU $FF68
DEF BGPD EQU $FF69
DEF OBPI EQU $FF6A
DEF OBPB EQU $FF6B

; SGB Commands
PAL_TRN EQU $59
DATA_SND EQU $79
MLT_REQ EQU $89
CHR_TRN EQU $99
PCT_TRN EQU $A1
MASK_EN EQU $B9
DEF PAL_TRN EQU $59
DEF DATA_SND EQU $79
DEF MLT_REQ EQU $89
DEF CHR_TRN EQU $99
DEF PCT_TRN EQU $A1
DEF MASK_EN EQU $B9

; DMA
START_DMA EQU $FF46
DMA_DELAY EQU $28
DMA EQU $FF80
DEF START_DMA EQU $FF46
DEF DMA_DELAY EQU $28
DEF DMA EQU $FF80

; OAM
OAM_SRC_START EQU $C800 / $100
DEF OAM_SRC_START EQU $C800 / $100

; Player struct
PLAYER_STRUCT_X_OFF EQU $0
PLAYER_STRUCT_Y_OFF EQU $1
DEF PLAYER_STRUCT_X_OFF EQU $0
DEF PLAYER_STRUCT_Y_OFF EQU $1

; Laser struct
LASER_STRUCT_X_OFF EQU $0
LASER_STRUCT_Y_OFF EQU $1
DEF LASER_STRUCT_X_OFF EQU $0
DEF LASER_STRUCT_Y_OFF EQU $1

; Sprite offsets
SPRITE_SIZE EQU $4
SPRITE_POSITION_Y EQU $0
SPRITE_POSITION_X EQU $1
SPRITE_TILE_NBR EQU $2
SPRITE_ATTRIBUTE_FLAGS EQU $3
DEF SPRITE_SIZE EQU $4
DEF SPRITE_POSITION_Y EQU $0
DEF SPRITE_POSITION_X EQU $1
DEF SPRITE_TILE_NBR EQU $2
DEF SPRITE_ATTRIBUTE_FLAGS EQU $3

; Obstacles registers
; All the obstacles will be added by incrementing the base register
ASTEROID_SPRITE_INDEX EQU $8
DEF ASTEROID_SPRITE_INDEX EQU $8

QUAVER EQU $8
DEF QUAVER EQU $8
4 changes: 2 additions & 2 deletions src/credits.asm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ credits::
or [hl]
jr z, .nextText
dec [hl]
jr .skip
jp .skip

.newLine:
reg CREDITS_LINE_POS, $A0
Expand Down Expand Up @@ -204,4 +204,4 @@ credits::
reg INTERRUPT_ENABLED, VBLANK_INTERRUPT
reset SCROLL_X
di
jp mainMenu.lateInit
jp mainMenu.lateInit
6 changes: 3 additions & 3 deletions src/macro.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
; bc -> Preserved
; de -> Preserved
; hl -> Preserved
reg: MACRO
MACRO reg
ld a, \2
ld [\1], a
ENDM

reset: MACRO
MACRO reset
xor a
ld [\1], a
ENDM
ENDM

0 comments on commit f9ac09a

Please sign in to comment.