Skip to content

Commit

Permalink
Merge pull request #5 from Engezerstorung/master
Browse files Browse the repository at this point in the history
2024-09-25 pokered update
  • Loading branch information
einstein95 committed Sep 26, 2024
2 parents 988184f + fe1a194 commit 685b04f
Show file tree
Hide file tree
Showing 115 changed files with 471 additions and 364 deletions.
10 changes: 5 additions & 5 deletions audio/engine_1.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Audio1_UpdateMusic::
ld a, [wMuteAudioAndPauseMusic]
and a
jr z, .applyAffects
bit 7, a
bit BIT_MUTE_AUDIO, a
jr nz, .nextChannel
set 7, a
set BIT_MUTE_AUDIO, a
ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output
ldh [rNR51], a
Expand Down Expand Up @@ -197,7 +197,7 @@ Audio1_sound_ret:
.dontDisable
jr .afterDisable
.returnFromCall
res 1, [hl]
res BIT_SOUND_CALL, [hl]
ld d, $0
ld a, c
add a
Expand Down Expand Up @@ -377,8 +377,8 @@ Audio1_toggle_perfect_pitch:
ld hl, wChannelFlags1
add hl, bc
ld a, [hl]
xor $1
ld [hl], a ; flip bit 0 of wChannelFlags1
xor 1 << BIT_PERFECT_PITCH
ld [hl], a
jp Audio1_sound_ret

Audio1_vibrato:
Expand Down
16 changes: 8 additions & 8 deletions audio/engine_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Audio2_UpdateMusic::
ld a, [wMuteAudioAndPauseMusic]
and a
jr z, .applyAffects
bit 7, a
bit BIT_MUTE_AUDIO, a
jr nz, .nextChannel
set 7, a
set BIT_MUTE_AUDIO, a
ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output
ldh [rNR51], a
Expand Down Expand Up @@ -163,8 +163,8 @@ Audio2_PlayNextNote:
ld a, c
cp CHAN5
jr nz, .beginChecks
ld a, [wLowHealthAlarm] ; low health alarm enabled?
bit 7, a
ld a, [wLowHealthAlarm]
bit BIT_LOW_HEALTH_ALARM, a
ret nz
.beginChecks
; ---
Expand Down Expand Up @@ -208,7 +208,7 @@ Audio2_sound_ret:
.dontDisable
jr .afterDisable
.returnFromCall
res 1, [hl]
res BIT_SOUND_CALL, [hl]
ld d, $0
ld a, c
add a
Expand Down Expand Up @@ -388,8 +388,8 @@ Audio2_toggle_perfect_pitch:
ld hl, wChannelFlags1
add hl, bc
ld a, [hl]
xor $1
ld [hl], a ; flip bit 0 of wChannelFlags1
xor 1 << BIT_PERFECT_PITCH
ld [hl], a
jp Audio2_sound_ret

Audio2_vibrato:
Expand Down Expand Up @@ -978,7 +978,7 @@ Audio2_ResetCryModifiers:
cp CHAN5
jr nz, .skip
ld a, [wLowHealthAlarm]
bit 7, a
bit BIT_LOW_HEALTH_ALARM, a
jr z, .skip
xor a
ld [wFrequencyModifier], a
Expand Down
10 changes: 5 additions & 5 deletions audio/engine_3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Audio3_UpdateMusic::
ld a, [wMuteAudioAndPauseMusic]
and a
jr z, .applyAffects
bit 7, a
bit BIT_MUTE_AUDIO, a
jr nz, .nextChannel
set 7, a
set BIT_MUTE_AUDIO, a
ld [wMuteAudioAndPauseMusic], a
xor a ; disable all channels' output
ldh [rNR51], a
Expand Down Expand Up @@ -197,7 +197,7 @@ Audio3_sound_ret:
.dontDisable
jr .afterDisable
.returnFromCall
res 1, [hl]
res BIT_SOUND_CALL, [hl]
ld d, $0
ld a, c
add a
Expand Down Expand Up @@ -377,8 +377,8 @@ Audio3_toggle_perfect_pitch:
ld hl, wChannelFlags1
add hl, bc
ld a, [hl]
xor $1
ld [hl], a ; flip bit 0 of wChannelFlags1
xor 1 << BIT_PERFECT_PITCH
ld [hl], a
jp Audio3_sound_ret

Audio3_vibrato:
Expand Down
14 changes: 7 additions & 7 deletions audio/low_health_alarm.asm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Music_DoLowHealthAlarm::
ld a, [wLowHealthAlarm]
cp $ff
cp DISABLE_LOW_HEALTH_ALARM
jr z, .disableAlarm

bit 7, a ;alarm enabled?
ret z ;nope
bit BIT_LOW_HEALTH_ALARM, a
ret z

and $7f ;low 7 bits are the timer.
and LOW_HEALTH_TIMER_MASK
jr nz, .notToneHi ;if timer > 0, play low tone.

call .playToneHi
Expand All @@ -19,15 +19,15 @@ Music_DoLowHealthAlarm::
call .playToneLo ;actually set the sound registers.

.noTone
ld a, $86
ld a, CRY_SFX_END
ld [wChannelSoundIDs + CHAN5], a ;disable sound channel?
ld a, [wLowHealthAlarm]
and $7f ;decrement alarm timer.
and LOW_HEALTH_TIMER_MASK
dec a

.resetTimer
; reset the timer and enable flag.
set 7, a
set BIT_LOW_HEALTH_ALARM, a
ld [wLowHealthAlarm], a
ret

Expand Down
8 changes: 8 additions & 0 deletions constants/audio_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ DEF HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)

; wChannelFlags2 constant (only has one flag)
DEF BIT_EXECUTE_MUSIC EQU 0 ; if in execute music

; wMuteAudioAndPauseMusic
DEF BIT_MUTE_AUDIO EQU 7

; wLowHealthAlarm
DEF BIT_LOW_HEALTH_ALARM EQU 7
DEF LOW_HEALTH_TIMER_MASK EQU %01111111
DEF DISABLE_LOW_HEALTH_ALARM EQU $ff
4 changes: 4 additions & 0 deletions constants/battle_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ DEF MAX_STAT_VALUE EQU 999
DEF ATKDEFDV_TRAINER EQU $98
DEF SPDSPCDV_TRAINER EQU $88

; wDamageMultipliers
DEF BIT_STAB_DAMAGE EQU 7
DEF EFFECTIVENESS_MASK EQU %01111111

; wPlayerBattleStatus1 or wEnemyBattleStatus1 bit flags
const_def
const STORING_ENERGY ; 0 ; Bide
Expand Down
6 changes: 6 additions & 0 deletions constants/gfx_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ DEF TRANSFERBOTTOM EQU 2
DEF REDRAW_COL EQU 1
DEF REDRAW_ROW EQU 2

; hUILayoutFlags
const_def
const BIT_PARTY_MENU_HP_BAR ; 0
const BIT_DOUBLE_SPACED_MENU ; 1
const BIT_SINGLE_SPACED_LINES ; 2

; tile list ids
; TileIDListPointerTable indexes (see data/tilemaps.asm)
const_def
Expand Down
15 changes: 13 additions & 2 deletions constants/hardware_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ DEF rWave_d EQU $ff3d
DEF rWave_e EQU $ff3e
DEF rWave_f EQU $ff3f
DEF rLCDC EQU $ff40 ; LCD Control (R/W)
DEF rLCDC_ENABLE EQU 7
DEF rLCDC_ENABLE_MASK EQU 1 << rLCDC_ENABLE
DEF rLCDC_BG_PRIORITY EQU 0
DEF rLCDC_SPRITES_ENABLE EQU 1
DEF rLCDC_SPRITE_SIZE EQU 2
DEF rLCDC_BG_TILEMAP EQU 3
DEF rLCDC_TILE_DATA EQU 4
DEF rLCDC_WINDOW_ENABLE EQU 5
DEF rLCDC_WINDOW_TILEMAP EQU 6
DEF rLCDC_ENABLE EQU 7
DEF rSTAT EQU $ff41 ; LCDC Status (R/W)
DEF rSCY EQU $ff42 ; Scroll Y (R/W)
DEF rSCX EQU $ff43 ; Scroll X (R/W)
Expand Down Expand Up @@ -111,3 +117,8 @@ DEF rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank
DEF rPCM12 EQU $ff76 ; Channels 1 & 2 Amplitude (R)
DEF rPCM34 EQU $ff77 ; Channels 3 & 4 Amplitude (R)
DEF rIE EQU $ffff ; Interrupt Enable (R/W)
DEF rIE_VBLANK EQU 0
DEF rIE_LCD EQU 1
DEF rIE_TIMER EQU 2
DEF rIE_SERIAL EQU 3
DEF rIE_JOYPAD EQU 4
24 changes: 12 additions & 12 deletions constants/icon_constants.asm
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
; party menu icons
; used in MonPartySpritePointers (see data/icon_pointers.asm)
const_def
const ICON_MON ; $0
const ICON_BALL ; $1
const ICON_HELIX ; $2
const ICON_FAIRY ; $3
const ICON_BIRD ; $4
const ICON_WATER ; $5
const ICON_BUG ; $6
const ICON_GRASS ; $7
const ICON_SNAKE ; $8
const ICON_QUADRUPED ; $9

DEF ICON_TRADEBUBBLE EQU $e
const ICON_MON ; $0
const ICON_BALL ; $1
const ICON_HELIX ; $2
const ICON_FAIRY ; $3
const ICON_BIRD ; $4
const ICON_WATER ; $5
const ICON_BUG ; $6
const ICON_GRASS ; $7
const ICON_SNAKE ; $8
const ICON_QUADRUPED ; $9
const_skip 4
const ICON_TRADEBUBBLE ; $e

DEF ICONOFFSET EQU $40 ; difference between alternating icon frames' tile IDs
11 changes: 9 additions & 2 deletions constants/map_object_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ DEF SPRITESTATEDATA2_LENGTH EQU const_value

DEF NUM_SPRITESTATEDATA_STRUCTS EQU 16

const_def 6
const BIT_TRAINER ; 6
const BIT_ITEM ; 7

; different kinds of people events
DEF ITEM EQU $80
DEF TRAINER EQU $40
DEF TRAINER EQU 1 << BIT_TRAINER
DEF ITEM EQU 1 << BIT_ITEM

; movement status
DEF BIT_FACE_PLAYER EQU 7

DEF WALK EQU $FE
DEF STAY EQU $FF
Expand Down
3 changes: 3 additions & 0 deletions constants/menu_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ DEF PC_ITEM_CAPACITY EQU 50
const NO_YES_MENU ; 7
DEF NUM_TWO_OPTION_MENUS EQU const_value

; wTwoOptionMenuID
DEF BIT_SECOND_MENU_OPTION_DEFAULT EQU 7

; menu exit method constants for list menus and the buy/sell/quit menu
DEF CHOSE_MENU_ITEM EQU 1 ; pressed A
DEF CANCELLED_MENU EQU 2 ; pressed B
Expand Down
24 changes: 15 additions & 9 deletions constants/oam_constants.asm
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
; OAM flags used by this game
DEF OAMFLAG_ENDOFDATA EQU %00000001 ; pseudo OAM flag, only used by game logic
DEF OAMFLAG_CANBEMASKED EQU %00000010 ; pseudo OAM flag, only used by game logic
; Pseudo-OAM flags used by game logic
const_def
const BIT_END_OF_OAM_DATA ; 0
const BIT_SPRITE_UNDER_GRASS ; 1

; Used in SpriteFacingAndAnimationTable (see data/sprites/facings.asm)
DEF FACING_END EQU 1 << BIT_END_OF_OAM_DATA
DEF UNDER_GRASS EQU 1 << BIT_SPRITE_UNDER_GRASS

; OAM attribute flags
DEF OAM_PALETTE EQU %111
DEF OAM_TILE_BANK EQU 3
DEF OAM_OBP_NUM EQU 4 ; Non CGB Mode Only
DEF OAM_X_FLIP EQU 5
DEF OAM_Y_FLIP EQU 6
DEF OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3)
DEF OAM_PALETTE EQU %111
const_def 3
const OAM_TILE_BANK ; 3
const OAM_OBP_NUM ; 4 ; Non CGB Mode Only
const OAM_X_FLIP ; 5
const OAM_Y_FLIP ; 6
const OAM_PRIORITY ; 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3)

; OAM attribute masks
DEF OAM_OBP1 EQU 1 << OAM_OBP_NUM ; OBJ palette 1
Expand Down
36 changes: 36 additions & 0 deletions constants/ram_constants.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
; wSlotMachineFlags
const_def 6
const BIT_SLOTS_CAN_WIN ; 6
const BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR ; 7

; wMiscFlags
const_def
const BIT_SEEN_BY_TRAINER ; 0
Expand All @@ -9,6 +14,21 @@
const BIT_TRIED_PUSH_BOULDER ; 6
const BIT_PUSHED_BOULDER ; 7

; wAutoTextBoxDrawingControl
DEF BIT_NO_AUTO_TEXT_BOX EQU 0

; wTextPredefFlag
DEF BIT_TEXT_PREDEF EQU 0

; wFontLoaded
DEF BIT_FONT_LOADED EQU 0

; wCurrentMapScriptFlags
const_def 5
const BIT_CUR_MAP_LOADED_1 ; 5
const BIT_CUR_MAP_LOADED_2 ; 6
const BIT_CUR_MAP_USED_ELEVATOR ; 7

; wOptions
DEF TEXT_DELAY_MASK EQU %111
const_def 6
Expand All @@ -24,6 +44,12 @@ DEF TEXT_DELAY_SLOW EQU %101 ; 5
const BIT_FAST_TEXT_DELAY ; 0
const BIT_TEXT_DELAY ; 1

; wCurMapTileset
DEF BIT_NO_PREVIOUS_MAP EQU 7

; wCurrentBoxNum
DEF BIT_HAS_CHANGED_BOXES EQU 7

; wObtainedBadges, wBeatGymFlags
const_def
const BIT_BOULDERBADGE ; 0
Expand Down Expand Up @@ -117,3 +143,13 @@ DEF NUM_BADGES EQU const_value
const_skip 3 ; 3-5 ; unused
const BIT_LEDGE_OR_FISHING ; 6
const BIT_SPINNING ; 7

; hFindPathFlags
const_def
const BIT_PATH_FOUND_Y ; 0
const BIT_PATH_FOUND_X ; 1

; hNPCPlayerRelativePosFlags
const_def
const BIT_PLAYER_LOWER_Y ; 0
const BIT_PLAYER_LOWER_X ; 1
8 changes: 4 additions & 4 deletions data/sprites/facings.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ SpriteFacingAndAnimationTable:
; y, x, attributes
db 0, 0, $00 ; top left
db 0, 8, $00 ; top right
db 8, 0, OAMFLAG_CANBEMASKED ; bottom left
db 8, 8, OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
db 8, 0, UNDER_GRASS ; bottom left
db 8, 8, UNDER_GRASS | FACING_END ; bottom right

.FlippedOAM:
; y, x, attributes
db 0, 8, OAM_HFLIP ; top left
db 0, 0, OAM_HFLIP ; top right
db 8, 8, OAM_HFLIP | OAMFLAG_CANBEMASKED ; bottom left
db 8, 0, OAM_HFLIP | OAMFLAG_CANBEMASKED | OAMFLAG_ENDOFDATA ; bottom right
db 8, 8, OAM_HFLIP | UNDER_GRASS ; bottom left
db 8, 0, OAM_HFLIP | UNDER_GRASS | FACING_END ; bottom right
6 changes: 3 additions & 3 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ DrawFrameBlock:
ld [de], a ; store tile ID
inc de
ld a, [hli]
bit 5, a ; is horizontal flip enabled?
bit OAM_X_FLIP, a
jr nz, .disableHorizontalFlip
.enableHorizontalFlip
set 5, a
set OAM_X_FLIP, a
jr .storeFlags2
.disableHorizontalFlip
res 5, a
res OAM_X_FLIP, a
.storeFlags2
ld [de], a
inc de
Expand Down
Loading

0 comments on commit 685b04f

Please sign in to comment.