Merge pull request #188 from yenatch/split-common

recomment and split out a ton of common asm (bank 0)
This commit is contained in:
Bryan Bishop 2013-09-05 11:30:12 -07:00
commit 40b4c87db7
16 changed files with 7346 additions and 2969 deletions

View File

@ -23,99 +23,7 @@ FarCall EQU $08
Bankswitch EQU $10
JumpTable EQU $28
dwb: MACRO
dw \1
db \2
ENDM
dbw: MACRO
db \1
dw \2
ENDM
dn: MACRO
db \1 << 4 + \2
ENDM
dt: MACRO ; three-byte (big-endian)
db (\1 >> 16) & $ff
db (\1 >> 8) & $ff
db \1 & $ff
ENDM
bigdw: MACRO ; big-endian word
dw ((\1)/$100) + (((\1)&$ff)*$100)
ENDM
callab: MACRO ; address, bank
ld hl, \1
ld a, BANK(\1)
rst FarCall
ENDM
callba: MACRO ; bank, address
ld a, BANK(\1)
ld hl, \1
rst FarCall
ENDM
TX_RAM: MACRO
db 1
dw \1
ENDM
TX_FAR: MACRO
db $16
dw \1
db BANK(\1)
ENDM
RGB: MACRO
dw ((\3 << 10) | (\2 << 5) | (\1))
ENDM
note: MACRO
db \1
ENDM
; It's better to use *coord than FuncCoord.
FuncCoord: MACRO
Coord = $c4a0 + 20 * \2 + \1
ENDM
bccoord: MACRO
FuncCoord \1, \2
ld bc, Coord
ENDM
decoord: MACRO
FuncCoord \1, \2
ld de, Coord
ENDM
hlcoord: MACRO
FuncCoord \1, \2
ld hl, Coord
ENDM
; pic animations
frame: MACRO
db \1
db \2
ENDM
setrepeat: MACRO
db $fe
db \1
ENDM
dorepeat: MACRO
db $fd
db \1
ENDM
endanim: MACRO
db $ff
ENDM
INCLUDE "macros.asm"
NONE EQU 0

23
engine/delay.asm Normal file
View File

@ -0,0 +1,23 @@
DelayFrame: ; 45a
; Wait for one frame
ld a, 1
ld [VBlankOccurred], a
; Wait for the next VBlank, halting to conserve battery
.halt
halt ; rgbasm adds a nop after this instruction by default
ld a, [VBlankOccurred]
and a
jr nz, .halt
ret
; 468
DelayFrames: ; 468
; Wait c frames
call DelayFrame
dec c
jr nz, DelayFrames
ret
; 46f

55
engine/farcall.asm Normal file
View File

@ -0,0 +1,55 @@
FarCall_de: ; 2d54
; Call a:de.
; Preserves other registers.
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
call .de
jr ReturnFarCall
.de
push de
ret
; 2d63
FarCall_hl: ; 2d63
; Call a:hl.
; Preserves other registers.
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
call Function2d82
; 2d6e
ReturnFarCall: ; 2d6e
; We want to retain the contents of f.
; To do this, we can pop to bc instead of af.
ld a, b
ld [$cfb9], a
ld a, c
ld [$cfba], a
; Restore the working bank.
pop bc
ld a, b
rst Bankswitch
ld a, [$cfb9]
ld b, a
ld a, [$cfba]
ld c, a
ret
; 2d82
Function2d82: ; 2d82
jp [hl]
; 2d83

132
engine/game_time.asm Normal file
View File

@ -0,0 +1,132 @@
ResetGameTime: ; 208a
xor a
ld [GameTimeCap], a
ld [GameTimeHours], a
ld [GameTimeHours + 1], a
ld [GameTimeMinutes], a
ld [GameTimeSeconds], a
ld [GameTimeFrames], a
ret
; 209e
GameTimer: ; 209e
nop
ld a, [rSVBK]
push af
ld a, 1
ld [rSVBK], a
call UpdateGameTimer
pop af
ld [rSVBK], a
ret
; 20ad
UpdateGameTimer: ; 20ad
; Increment the game timer by one frame.
; The game timer is capped at 999:59:59.00.
; Don't update if game logic is paused.
ld a, [$c2cd]
and a
ret nz
; Is the timer paused?
ld hl, GameTimerPause
bit 0, [hl]
ret z
; Is the timer already capped?
ld hl, GameTimeCap
bit 0, [hl]
ret nz
; +1 frame
ld hl, GameTimeFrames
ld a, [hl]
inc a
cp 60 ; frames/second
jr nc, .second
ld [hl], a
ret
.second
xor a
ld [hl], a
; +1 second
ld hl, GameTimeSeconds
ld a, [hl]
inc a
cp 60 ; seconds/minute
jr nc, .minute
ld [hl], a
ret
.minute
xor a
ld [hl], a
; +1 minute
ld hl, GameTimeMinutes
ld a, [hl]
inc a
cp 60 ; minutes/hour
jr nc, .hour
ld [hl], a
ret
.hour
xor a
ld [hl], a
; +1 hour
ld a, [GameTimeHours]
ld h, a
ld a, [GameTimeHours + 1]
ld l, a
inc hl
; Cap the timer after 1000 hours.
ld a, h
cp 1000 / $100
jr c, .ok
ld a, l
cp 1000 % $100
jr c, .ok
ld hl, GameTimeCap
set 0, [hl]
ld a, 59 ; 999:59:59.00
ld [GameTimeMinutes], a
ld [GameTimeSeconds], a
ret
.ok
ld a, h
ld [GameTimeHours], a
ld a, l
ld [GameTimeHours + 1], a
ret
; 210f

683
engine/map_objects.asm Normal file

File diff suppressed because it is too large Load Diff

603
engine/menu.asm Normal file

File diff suppressed because it is too large Load Diff

25
engine/rtc.asm Normal file
View File

@ -0,0 +1,25 @@
RTC: ; 46f
; update time and time-sensitive palettes
; rtc enabled?
ld a, [$c2ce]
cp 0
ret z
call UpdateTime
; obj update on?
ld a, [VramState]
bit 0, a ; obj update
ret z
TimeOfDayPals: ; 47e
callab _TimeOfDayPals
ret
; 485
UpdateTimePals: ; 485
callab _UpdateTimePals
ret
; 48c

22
engine/sine.asm Normal file
View File

@ -0,0 +1,22 @@
Cosine: ; 1b0f
; Return d * cos(a) in hl
add $10 ; 90 degrees
Sine: ; 1b11
; Return d * sin(a) in hl
; a is a signed 6-bit value.
ld e, a
ld a, [hROMBank]
push af
ld a, BANK(_Sine)
rst Bankswitch
call _Sine
pop af
rst Bankswitch
ret
; 1b1e

487
engine/video.asm Normal file
View File

@ -0,0 +1,487 @@
; Functions dealing with VRAM.
DMATransfer: ; 15d8
; Return carry if the transfer is completed.
ld a, [hDMATransfer]
and a
ret z
; Start transfer
ld [rHDMA5], a
; Execution is halted until the transfer is complete.
xor a
ld [hDMATransfer], a
scf
ret
; 15e3
UpdateBGMapBuffer: ; 15e3
; Copy [$ffdc] 16x8 tiles from BGMapBuffer
; to bg map addresses in BGMapBufferPtrs.
; [$ffdc] must be even since this is done in pairs.
; Return carry on success.
ld a, [hBGMapUpdate]
and a
ret z
ld a, [rVBK]
push af
ld [hSPBuffer], sp
ld hl, BGMapBufferPtrs
ld sp, hl
; We can now pop the addresses of affected spots on the BG Map
ld hl, BGMapPalBuffer
ld de, BGMapBuffer
.next
; Copy a pair of 16x8 blocks (one 16x16 block)
rept 2
; Get our BG Map address
pop bc
; Palettes
ld a, 1
ld [rVBK], a
ld a, [hli]
ld [bc], a
inc c
ld a, [hli]
ld [bc], a
dec c
; Tiles
ld a, 0
ld [rVBK], a
ld a, [de]
inc de
ld [bc], a
inc c
ld a, [de]
inc de
ld [bc], a
endr
; We've done 2 16x8 blocks
ld a, [$ffdc]
dec a
dec a
ld [$ffdc], a
jr nz, .next
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
pop af
ld [rVBK], a
xor a
ld [hBGMapUpdate], a
scf
ret
; 163a
WaitTop: ; 163a
; Wait until the top third of the BG Map is being updated.
ld a, [hBGMapMode]
and a
ret z
ld a, [hBGMapThird]
and a
jr z, .done
call DelayFrame
jr WaitTop
.done
xor a
ld [hBGMapMode], a
ret
; 164c
UpdateBGMap: ; 164c
; Update the BG Map, in thirds, from TileMap and AttrMap.
ld a, [hBGMapMode]
and a
ret z
; BG Map 0
dec a ; 1
jr z, .Tiles
dec a ; 2
jr z, .Attr
; BG Map 1
dec a
ld a, [hBGMapAddress]
ld l, a
ld a, [hBGMapAddress + 1]
ld h, a
push hl
xor a
ld [hBGMapAddress], a
ld a, VBGMap1 >> 8
ld [hBGMapAddress + 1], a
ld a, [hBGMapMode]
push af
cp 3
call z, .Tiles
pop af
cp 4
call z, .Attr
pop hl
ld a, l
ld [hBGMapAddress], a
ld a, h
ld [hBGMapAddress + 1], a
ret
.Attr
ld a, 1
ld [rVBK], a
ld hl, AttrMap
call .update
ld a, 0
ld [rVBK], a
ret
.Tiles
ld hl, TileMap
.update
ld [hSPBuffer], sp
; Which third?
ld a, [hBGMapThird]
and a ; 0
jr z, .top
dec a ; 1
jr z, .middle
; 2
THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
.bottom
ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH
add hl, de
ld sp, hl
ld a, [hBGMapAddress + 1]
ld h, a
ld a, [hBGMapAddress]
ld l, a
ld de, 2 * THIRD_HEIGHT * BG_MAP_WIDTH
add hl, de
; Next time: top third
xor a
jr .start
.middle
ld de, THIRD_HEIGHT * SCREEN_WIDTH
add hl, de
ld sp, hl
ld a, [hBGMapAddress + 1]
ld h, a
ld a, [hBGMapAddress]
ld l, a
ld de, THIRD_HEIGHT * BG_MAP_WIDTH
add hl, de
; Next time: bottom third
ld a, 2
jr .start
.top
ld sp, hl
ld a, [hBGMapAddress + 1]
ld h, a
ld a, [hBGMapAddress]
ld l, a
; Next time: middle third
ld a, 1
.start
; Which third to update next time
ld [hBGMapThird], a
; Rows of tiles in a third
ld a, SCREEN_HEIGHT / 3
; Discrepancy between TileMap and BGMap
ld bc, BG_MAP_WIDTH - (SCREEN_WIDTH - 1)
.row
; Copy a row of 20 tiles
rept SCREEN_WIDTH / 2 - 1
pop de
ld [hl], e
inc l
ld [hl], d
inc l
endr
pop de
ld [hl], e
inc l
ld [hl], d
add hl, bc
dec a
jr nz, .row
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret
; 170a
Serve1bppRequest: ; 170a
; Only call during the first fifth of VBlank
ld a, [Requested1bpp]
and a
ret z
; Back out if we're too far into VBlank
ld a, [rLY]
cp 144
ret c
cp 146
ret nc
; Copy [Requested1bpp] 1bpp tiles from [Requested1bppSource] to [Requested1bppDest]
ld [hSPBuffer], sp
; Source
ld hl, Requested1bppSource
ld a, [hli]
ld h, [hl]
ld l, a
ld sp, hl
; Destination
ld hl, Requested1bppDest
ld a, [hli]
ld h, [hl]
ld l, a
; # tiles to copy
ld a, [Requested1bpp]
ld b, a
xor a
ld [Requested1bpp], a
.next
rept 3
pop de
ld [hl], e
inc l
ld [hl], e
inc l
ld [hl], d
inc l
ld [hl], d
inc l
endr
pop de
ld [hl], e
inc l
ld [hl], e
inc l
ld [hl], d
inc l
ld [hl], d
inc hl
dec b
jr nz, .next
ld a, l
ld [Requested1bppDest], a
ld a, h
ld [Requested1bppDest + 1], a
ld [Requested1bppSource], sp
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret
; 1769
Serve2bppRequest: ; 1769
; Only call during the first fifth of VBlank
ld a, [Requested2bpp]
and a
ret z
; Back out if we're too far into VBlank
ld a, [rLY]
cp 144
ret c
cp 146
ret nc
jr _Serve2bppRequest
Serve2bppRequest@VBlank: ; 1778
ld a, [Requested2bpp]
and a
ret z
_Serve2bppRequest: ; 177d
; Copy [Requested2bpp] 2bpp tiles from [Requested2bppSource] to [Requested2bppDest]
ld [hSPBuffer], sp
; Source
ld hl, Requested2bppSource
ld a, [hli]
ld h, [hl]
ld l, a
ld sp, hl
; Destination
ld hl, Requested2bppDest
ld a, [hli]
ld h, [hl]
ld l, a
; # tiles to copy
ld a, [Requested2bpp]
ld b, a
xor a
ld [Requested2bpp], a
.next
rept 7
pop de
ld [hl], e
inc l
ld [hl], d
inc l
endr
pop de
ld [hl], e
inc l
ld [hl], d
inc hl
dec b
jr nz, .next
ld a, l
ld [Requested2bppDest], a
ld a, h
ld [Requested2bppDest + 1], a
ld [Requested2bppSource], sp
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret
; 17d3
AnimateTileset: ; 17d3
; Only call during the first fifth of VBlank
ld a, [$ffde]
and a
ret z
; Back out if we're too far into VBlank
ld a, [rLY]
cp 144
ret c
cp 151
ret nc
ld a, [hROMBank]
push af
ld a, BANK(_AnimateTileset)
rst Bankswitch
ld a, [rSVBK]
push af
ld a, 1
ld [rSVBK], a
ld a, [rVBK]
push af
ld a, 0
ld [rVBK], a
call _AnimateTileset
pop af
ld [rVBK], a
pop af
ld [rSVBK], a
pop af
rst Bankswitch
ret
; 17ff

17
interrupts.asm Normal file
View File

@ -0,0 +1,17 @@
; Game Boy hardware interrupts
SECTION "vblank",ROM0[$40]
jp VBlank
SECTION "lcd",ROM0[$48]
jp LCD
SECTION "timer",ROM0[$50]
jp Timer
SECTION "serial",ROM0[$58]
jp Serial
SECTION "joypad",ROM0[$60]
jp JoypadInt

443
items/marts.asm Normal file
View File

@ -0,0 +1,443 @@
Marts: ; 160a9
dw Mart0
dw Mart1
dw Mart2
dw Mart3
dw Mart4
dw Mart5
dw Mart6
dw Mart7
dw Mart8
dw Mart9
dw Mart10
dw Mart11
dw Mart12
dw Mart13
dw Mart14
dw Mart15
dw Mart16
dw Mart17
dw Mart18
dw Mart19
dw Mart20
dw Mart21
dw Mart22
dw Mart23
dw Mart24
dw Mart25
dw Mart26
dw Mart27
dw Mart28
dw Mart29
dw Mart30
dw Mart31
dw Mart32
dw Mart33
MartsEnd
; 160ed
Mart0: ; 160ed
db 4 ; # items
db POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db $ff
; 160f3
Mart1: ; 160f3
db 5 ; # items
db POKE_BALL
db POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db $ff
; 160fa
Mart2: ; 160fa
db 10 ; # items
db POKE_BALL
db POTION
db ESCAPE_ROPE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db X_DEFEND
db X_ATTACK
db X_SPEED
db FLOWER_MAIL
db $ff
; 16106
Mart3: ; 16106
db 9 ; # items
db CHARCOAL
db POKE_BALL
db POTION
db SUPER_POTION
db ESCAPE_ROPE
db REPEL
db ANTIDOTE
db PARLYZ_HEAL
db FLOWER_MAIL
db $ff
; 16111
Mart4: ; 16111
db 5 ; # items
db POTION
db SUPER_POTION
db HYPER_POTION
db FULL_HEAL
db REVIVE
db $ff
; 16118
Mart5: ; 16118
db 7 ; # items
db POTION
db SUPER_POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db $ff
; 16121
Mart6: ; 16121
db 8 ; # items
db POKE_BALL
db GREAT_BALL
db ESCAPE_ROPE
db REPEL
db REVIVE
db FULL_HEAL
db POKE_DOLL
db FLOWER_MAIL
db $ff
; 1612b
Mart7: ; 1612b
db 7 ; # items
db X_SPEED
db X_SPECIAL
db X_DEFEND
db X_ATTACK
db DIRE_HIT
db GUARD_SPEC
db X_ACCURACY
db $ff
; 16134
Mart8: ; 16134
db 5 ; # items
db PROTEIN
db IRON
db CARBOS
db CALCIUM
db HP_UP
db $ff
; 1613b
Mart9: ; 1613b
db 3 ; # items
db TM_41
db TM_48
db TM_33
db $ff
; 16140
Mart10: ; 16140
db 4 ; # items
db TM_41
db TM_48
db TM_33
db TM_02
db $ff
; 16146
Mart11: ; 16146
db 4 ; # items
db TM_41
db TM_48
db TM_33
db TM_08
db $ff
; 1614c
Mart12: ; 1614c
db 5 ; # items
db TM_41
db TM_48
db TM_33
db TM_02
db TM_08
db $ff
; 16153
Mart13: ; 16153
db 9 ; # items
db GREAT_BALL
db SUPER_POTION
db HYPER_POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db ICE_HEAL
db SUPER_REPEL
db SURF_MAIL
db $ff
; 1615e
Mart14: ; 1615e
db 10 ; # items
db POKE_BALL
db GREAT_BALL
db POTION
db SUPER_POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db REVIVE
db $ff
; 1616a
Mart15: ; 1616a
db 4 ; # items
db TINYMUSHROOM
db SLOWPOKETAIL
db POKE_BALL
db POTION
db $ff
; 16170
Mart16: ; 16170
db 9 ; # items
db RAGECANDYBAR
db GREAT_BALL
db SUPER_POTION
db HYPER_POTION
db ANTIDOTE
db PARLYZ_HEAL
db SUPER_REPEL
db REVIVE
db FLOWER_MAIL
db $ff
; 1617b
Mart17: ; 1617b
db 9 ; # items
db GREAT_BALL
db ULTRA_BALL
db HYPER_POTION
db MAX_POTION
db FULL_HEAL
db REVIVE
db MAX_REPEL
db X_DEFEND
db X_ATTACK
db $ff
; 16186
Mart18: ; 16186
db 9 ; # items
db ULTRA_BALL
db HYPER_POTION
db FULL_HEAL
db REVIVE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db FLOWER_MAIL
db $ff
; 16191
Mart19: ; 16191
db 7 ; # items
db GREAT_BALL
db SUPER_POTION
db SUPER_REPEL
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db $ff
; 1619a
Mart20: ; 1619a
db 9 ; # items
db GREAT_BALL
db ULTRA_BALL
db SUPER_POTION
db SUPER_REPEL
db FULL_HEAL
db X_DEFEND
db X_ATTACK
db DIRE_HIT
db SURF_MAIL
db $ff
; 161a5
Mart21: ; 161a5
db 8 ; # items
db GREAT_BALL
db POTION
db SUPER_POTION
db MAX_REPEL
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db $ff
; 161af
Mart22: ; 161af
db 8 ; # items
db ULTRA_BALL
db SUPER_POTION
db HYPER_POTION
db REVIVE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db LITEBLUEMAIL
db $ff
; 161b9
Mart23: ; 161b9
db 7 ; # items
db POTION
db SUPER_POTION
db HYPER_POTION
db MAX_POTION
db REVIVE
db SUPER_REPEL
db MAX_REPEL
db $ff
; 161c2
Mart24: ; 161c2
db 10 ; # items
db POKE_BALL
db GREAT_BALL
db ULTRA_BALL
db ESCAPE_ROPE
db FULL_HEAL
db ANTIDOTE
db BURN_HEAL
db ICE_HEAL
db AWAKENING
db PARLYZ_HEAL
db $ff
; 161ce
Mart25: ; 161ce
db 5 ; # items
db TM_10
db TM_11
db TM_17
db TM_18
db TM_37
db $ff
; 161d5
Mart26: ; 161d5
db 3 ; # items
db POKE_DOLL
db LOVELY_MAIL
db SURF_MAIL
db $ff
; 161da
Mart27: ; 161da
db 5 ; # items
db HP_UP
db PROTEIN
db IRON
db CARBOS
db CALCIUM
db $ff
; 161e1
Mart28: ; 161e1
db 7 ; # items
db X_ACCURACY
db GUARD_SPEC
db DIRE_HIT
db X_ATTACK
db X_DEFEND
db X_SPEED
db X_SPECIAL
db $ff
; 161ea
Mart29: ; 161ea
db 7 ; # items
db GREAT_BALL
db ULTRA_BALL
db SUPER_POTION
db HYPER_POTION
db FULL_HEAL
db MAX_REPEL
db FLOWER_MAIL
db $ff
; 161f3
Mart30: ; 161f3
db 8 ; # items
db GREAT_BALL
db ULTRA_BALL
db HYPER_POTION
db MAX_POTION
db FULL_HEAL
db X_ATTACK
db X_DEFEND
db FLOWER_MAIL
db $ff
; 161fd
Mart31: ; 161fd
db 6 ; # items
db POKE_DOLL
db FRESH_WATER
db SODA_POP
db LEMONADE
db REPEL
db PORTRAITMAIL
db $ff
; 16205
Mart32: ; 16205
db 7 ; # items
db ULTRA_BALL
db MAX_REPEL
db HYPER_POTION
db MAX_POTION
db FULL_RESTORE
db REVIVE
db FULL_HEAL
db $ff
; 1620e
Mart33: ; 1620e
db 4 ; # items
db ENERGYPOWDER
db ENERGY_ROOT
db HEAL_POWDER
db REVIVAL_HERB
db $ff
; 16214
DefaultMart: ; 16214
db 2 ; # items
db POKE_BALL
db POTION
db $ff
; 16218

95
macros.asm Normal file
View File

@ -0,0 +1,95 @@
; rgbds macros
dwb: MACRO
dw \1
db \2
ENDM
dbw: MACRO
db \1
dw \2
ENDM
dn: MACRO
db \1 << 4 + \2
ENDM
dt: MACRO ; three-byte (big-endian)
db (\1 >> 16) & $ff
db (\1 >> 8) & $ff
db \1 & $ff
ENDM
bigdw: MACRO ; big-endian word
dw ((\1)/$100) + (((\1)&$ff)*$100)
ENDM
callab: MACRO ; address, bank
ld hl, \1
ld a, BANK(\1)
rst FarCall
ENDM
callba: MACRO ; bank, address
ld a, BANK(\1)
ld hl, \1
rst FarCall
ENDM
TX_RAM: MACRO
db 1
dw \1
ENDM
TX_FAR: MACRO
db $16
dw \1
db BANK(\1)
ENDM
RGB: MACRO
dw ((\3 << 10) | (\2 << 5) | (\1))
ENDM
note: MACRO
db \1
ENDM
; It's better to use *coord than FuncCoord.
FuncCoord: MACRO
Coord = $c4a0 + 20 * \2 + \1
ENDM
bccoord: MACRO
FuncCoord \1, \2
ld bc, Coord
ENDM
decoord: MACRO
FuncCoord \1, \2
ld de, Coord
ENDM
hlcoord: MACRO
FuncCoord \1, \2
ld hl, Coord
ENDM
; pic animations
frame: MACRO
db \1
db \2
ENDM
setrepeat: MACRO
db $fe
db \1
ENDM
dorepeat: MACRO
db $fd
db \1
ENDM
endanim: MACRO
db $ff
ENDM

7496
main.asm

File diff suppressed because it is too large Load Diff

38
rst.asm Normal file
View File

@ -0,0 +1,38 @@
; rst vectors
SECTION "rst0",ROM0[0]
di
jp Start
SECTION "rst8",ROM0[FarCall]
jp FarCall_hl
SECTION "rst10",ROM0[Bankswitch]
ld [hROMBank], a
ld [MBC3RomBank], a
ret
SECTION "rst18",ROM0[$18]
rst $38
SECTION "rst20",ROM0[$20]
rst $38
SECTION "rst28",ROM0[JumpTable]
push de
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
pop de
jp [hl]
; SECTION "rst30",ROM0[$30]
; rst30 is midst rst28
SECTION "rst38",ROM0[$38]
rst $38

93
trainers/dvs.asm Normal file
View File

@ -0,0 +1,93 @@
GetTrainerDVs: ; 270c4
; Return the DVs of OtherTrainerClass in bc
push hl
ld a, [OtherTrainerClass]
dec a
ld c, a
ld b, 0
ld hl, TrainerClassDVs
add hl, bc
add hl, bc
ld a, [hli]
ld b, a
ld c, [hl]
pop hl
ret
; 270d6
TrainerClassDVs: ; 270d6
; Atk Spd
; Def Spc
db $9A, $77 ; falkner
db $88, $88 ; bugsy
db $98, $88 ; whitney
db $98, $88 ; morty
db $98, $88 ; pryce
db $98, $88 ; jasmine
db $98, $88 ; chuck
db $7C, $DD ; clair
db $DD, $DD ; rival1
db $98, $88 ; pokemon prof
db $DC, $DD ; will
db $DC, $DD ; cal
db $DC, $DD ; bruno
db $7F, $DF ; karen
db $DC, $DD ; koga
db $DC, $DD ; champion
db $98, $88 ; brock
db $78, $88 ; misty
db $98, $88 ; lt surge
db $98, $88 ; scientist
db $78, $88 ; erika
db $98, $88 ; youngster
db $98, $88 ; schoolboy
db $98, $88 ; bird keeper
db $58, $88 ; lass
db $98, $88 ; janine
db $D8, $C8 ; cooltrainerm
db $7C, $C8 ; cooltrainerf
db $69, $C8 ; beauty
db $98, $88 ; pokemaniac
db $D8, $A8 ; gruntm
db $98, $88 ; gentleman
db $98, $88 ; skier
db $68, $88 ; teacher
db $7D, $87 ; sabrina
db $98, $88 ; bug catcher
db $98, $88 ; fisher
db $98, $88 ; swimmerm
db $78, $88 ; swimmerf
db $98, $88 ; sailor
db $98, $88 ; super nerd
db $98, $88 ; rival2
db $98, $88 ; guitarist
db $A8, $88 ; hiker
db $98, $88 ; biker
db $98, $88 ; blaine
db $98, $88 ; burglar
db $98, $88 ; firebreather
db $98, $88 ; juggler
db $98, $88 ; blackbelt
db $D8, $A8 ; executivem
db $98, $88 ; psychic
db $6A, $A8 ; picnicker
db $98, $88 ; camper
db $7E, $A8 ; executivef
db $98, $88 ; sage
db $78, $88 ; medium
db $98, $88 ; boarder
db $98, $88 ; pokefanm
db $68, $8A ; kimono girl
db $68, $A8 ; twins
db $6D, $88 ; pokefanf
db $FD, $DE ; red
db $9D, $DD ; blue
db $98, $88 ; officer
db $7E, $A8 ; gruntf
db $98, $88 ; mysticalman
; 2715c

View File

@ -860,7 +860,14 @@ TextDelayFrames: ; cfb2
VBlankOccurred: ; cfb3
ds 1
ds 8
PredefID: ; cfb4
ds 1
PredefTemp: ; cfb5
ds 2
PredefAddress: ; cfb7
ds 2
ds 3
GameTimerPause: ; cfbc
; bit 0