diff --git a/src/actors/breakfire.asm b/src/actors/breakfire.asm index 2c2a635e..cd5cbaa1 100644 --- a/src/actors/breakfire.asm +++ b/src/actors/breakfire.asm @@ -27,7 +27,7 @@ .IMPORT FuncA_Actor_CenterHitsTerrain .IMPORT FuncA_Actor_HarmAvatarIfCollision .IMPORT FuncA_Actor_NegateVelX -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeLeftHalfTile .IMPORT FuncA_Objects_MoveShapeUpOneTile .IMPORT FuncA_Objects_SetShapePosToActorCenter @@ -39,7 +39,6 @@ .IMPORT Ram_ActorState2_byte_arr .IMPORT Ram_ActorVelX_i16_0_arr .IMPORT Ram_ActorVelX_i16_1_arr -.IMPORT Ram_Oam_sObj_arr64 .IMPORTZP Zp_FrameCounter_u8 ;;;=========================================================================;;; @@ -149,26 +148,22 @@ _Expire: bcs _Tall _Short: lda #2 - sta T0 ; num tiles + sta T2 ; num tiles lda #kTileIdObjBreakfireFirst + 4 - sta T1 ; first tile ID + sta T3 ; first tile ID bne _Loop ; unconditional _Tall: lda #3 - sta T0 ; num tiles + sta T2 ; num tiles lda #kTileIdObjBreakfireFirst + 2 - sta T1 ; first tile ID + sta T3 ; first tile ID _Loop: - jsr FuncA_Objects_Alloc1x1Shape ; preserves X and T0+, returns C and Y - bcs @continue - lda T1 ; tile ID - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjBreakfire - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: + lda T3 ; param: tile ID + ldy #kPaletteObjBreakfire ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X and T2+ jsr FuncA_Objects_MoveShapeUpOneTile ; preserves X and T0+ - dec T1 ; tile ID - dec T0 ; num tiles + dec T3 ; tile ID + dec T2 ; num tiles bne _Loop rts .ENDPROC diff --git a/src/actors/explosion.asm b/src/actors/explosion.asm index 59ac1840..b1b94750 100644 --- a/src/actors/explosion.asm +++ b/src/actors/explosion.asm @@ -19,11 +19,10 @@ .INCLUDE "../actor.inc" .INCLUDE "../macros.inc" -.INCLUDE "../oam.inc" .INCLUDE "../ppu.inc" .INCLUDE "smoke.inc" -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeDownByA .IMPORT FuncA_Objects_MoveShapeLeftByA .IMPORT FuncA_Objects_MoveShapeLeftOneTile @@ -32,16 +31,17 @@ .IMPORT FuncA_Objects_MoveShapeUpOneTile .IMPORT FuncA_Objects_SetShapePosToActorCenter .IMPORT Func_InitActorDefault -.IMPORT Ram_ActorFlags_bObj_arr .IMPORT Ram_ActorState1_byte_arr .IMPORT Ram_ActorType_eActor_arr -.IMPORT Ram_Oam_sObj_arr64 ;;;=========================================================================;;; ;;; How long a smoke actor animates before disappearing, in frames. kSmokeNumFrames = 12 +;;; The OBJ palette number used for smoke explosion actors. +kPaletteObjExplosion = 0 + ;;;=========================================================================;;; .SEGMENT "PRG8" @@ -108,16 +108,11 @@ _TopRight: add #kTileHeightPx ; param: offset jsr FuncA_Objects_MoveShapeUpByA ; preserves X _DrawSmokeParticle: - jsr FuncA_Objects_Alloc1x1Shape ; preserves X - bcs @done lda Ram_ActorState1_byte_arr, x div #2 - add #kTileIdObjSmokeFirst - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda Ram_ActorFlags_bObj_arr, x - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @done: - rts + add #kTileIdObjSmokeFirst ; param: tile ID + ldy #kPaletteObjExplosion ; param: object flags + jmp FuncA_Objects_Draw1x1Shape ; preserves X .ENDPROC ;;;=========================================================================;;; diff --git a/src/devices/door.asm b/src/devices/door.asm index dfbff4c0..a8d6d51b 100644 --- a/src/devices/door.asm +++ b/src/devices/door.asm @@ -22,14 +22,13 @@ .INCLUDE "../oam.inc" .INCLUDE "../ppu.inc" -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeDownOneTile -.IMPORT FuncA_Objects_MoveShapeRightByA +.IMPORT FuncA_Objects_MoveShapeRightHalfTile .IMPORT FuncA_Objects_MoveShapeUpOneTile .IMPORT FuncA_Objects_SetShapePosToDeviceTopLeft .IMPORT Ram_DeviceAnim_u8_arr .IMPORT Ram_DeviceType_eDevice_arr -.IMPORT Ram_Oam_sObj_arr64 ;;;=========================================================================;;; @@ -119,30 +118,23 @@ kPaletteObjDoorway = 0 beq _Done ;; Start drawing from the bottom of the doorway. pha ; half-tiles - jsr FuncA_Objects_SetShapePosToDeviceTopLeft ; preserves X - jsr FuncA_Objects_MoveShapeDownOneTile ; preserves X - lda #kTileWidthPx / 2 ; param: offset - jsr FuncA_Objects_MoveShapeRightByA ; preserves X + jsr FuncA_Objects_SetShapePosToDeviceTopLeft ; preserves X and T0+ + jsr FuncA_Objects_MoveShapeDownOneTile ; preserves X and T0+ + jsr FuncA_Objects_MoveShapeRightHalfTile ; preserves X and T0+ pla ; half-tiles _Loop: - pha ; half-tiles - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns C and Y - bcs @continue - pla ; half-tiles pha ; half-tiles cmp #2 blt @half @full: - lda #kTileIdObjDoorwayFull - bne @setTileId ; unconditional + lda #kTileIdObjDoorwayFull ; param: tile ID + bne @draw ; unconditional @half: - lda #kTileIdObjDoorwayHalf - @setTileId: - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjDoorway - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: - jsr FuncA_Objects_MoveShapeUpOneTile + lda #kTileIdObjDoorwayHalf ; param: tile ID + @draw: + ldy #kPaletteObjDoorway ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X and T2+ + jsr FuncA_Objects_MoveShapeUpOneTile ; preserves X and T0+ pla ; half-tiles sub #2 blt _Done diff --git a/src/devices/lever.asm b/src/devices/lever.asm index 6691f1fe..b58440e7 100644 --- a/src/devices/lever.asm +++ b/src/devices/lever.asm @@ -24,13 +24,12 @@ .INCLUDE "lever.inc" .IMPORT FuncA_Machine_StartWaiting -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeDownByA .IMPORT FuncA_Objects_MoveShapeRightOneTile .IMPORT FuncA_Objects_SetShapePosToDeviceTopLeft .IMPORT Ram_DeviceAnim_u8_arr .IMPORT Ram_DeviceTarget_byte_arr -.IMPORT Ram_Oam_sObj_arr64 .IMPORTZP Zp_RoomState ;;;=========================================================================;;; @@ -208,8 +207,6 @@ _AdjustPosition: @moveDown: jsr FuncA_Objects_MoveShapeDownByA ; preserves X and T0+ _AllocateObject: - jsr FuncA_Objects_Alloc1x1Shape ; preserves X and T0+, returns C and Y - bcs @done stx T2 ; device index ldx T0 ; animation frame lda T1 ; object flags @@ -217,12 +214,10 @@ _AllocateObject: blt @noFlip eor #bObj::FlipH @noFlip: - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - lda _LeverTileIds_u8_arr, x - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y + tay ; param: object flags + lda _LeverTileIds_u8_arr, x ; param: tile ID ldx T2 ; device index - @done: - rts + jmp FuncA_Objects_Draw1x1Shape ; preserves X _LeverTileIds_u8_arr: .byte kTileIdObjLeverHandleDown .byte kTileIdObjLeverHandleUp diff --git a/src/machines/bridge.asm b/src/machines/bridge.asm index a09560a9..52604b23 100644 --- a/src/machines/bridge.asm +++ b/src/machines/bridge.asm @@ -28,8 +28,8 @@ .IMPORT FuncA_Machine_Error .IMPORT FuncA_Machine_ReachedGoal .IMPORT FuncA_Machine_StartWaiting -.IMPORT FuncA_Objects_Alloc1x1Shape .IMPORT FuncA_Objects_Alloc2x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_GetMachineLightTileId .IMPORT FuncA_Objects_MoveShapeDownOneTile .IMPORT FuncA_Objects_MoveShapeRightOneTile @@ -210,23 +210,17 @@ _Delta_u8_arr: .PROC FuncA_Objects_DrawBridgeMachine ldy #sMachine::MainPlatform_u8 lda (Zp_Current_sMachine_ptr), y + sta T2 ; pivot platform index _SegmentLoop: - pha ; pivot platform index - jsr FuncA_Objects_SetShapePosToPlatformTopLeft ; preserves X - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns Y and C - bcs @continue - lda #kTileIdObjBridgeSegment - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjBridgeSegment - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: - pla ; pivot platform index - sta T0 ; pivot platform index + jsr FuncA_Objects_SetShapePosToPlatformTopLeft ; preserves X and T0+ + lda #kTileIdObjBridgeSegment ; param: tile ID + ldy #kPaletteObjBridgeSegment ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X and T2+ dex - cpx T0 ; pivot platform index + cpx T2 ; pivot platform index bne _SegmentLoop _MainMachine: - tax ; param: platform index + ;; At this point, X holds the machine's pivot (main) platform index. jsr FuncA_Objects_SetShapePosToPlatformTopLeft jsr FuncA_Objects_MoveShapeDownOneTile ldy #sMachine::Flags_bMachine diff --git a/src/machines/crane.asm b/src/machines/crane.asm index c0d0a13e..fab66a93 100644 --- a/src/machines/crane.asm +++ b/src/machines/crane.asm @@ -25,7 +25,6 @@ .INCLUDE "shared.inc" .IMPORT FuncA_Machine_GetGenericMoveSpeed -.IMPORT FuncA_Objects_Alloc1x1Shape .IMPORT FuncA_Objects_Alloc2x2Shape .IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_DrawGirderPlatform @@ -144,23 +143,14 @@ _Claw: @done: _RightClaw: jsr FuncA_Objects_MoveShapeDownOneTile ; preserves X - jsr FuncA_Objects_Alloc1x1Shape ; preserves X; returns C and Y - bcs @done - txa ; tile ID - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjMachineLight | bObj::FlipH - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @done: + txa ; param: tile ID + ldy #kPaletteObjMachineLight | bObj::FlipH ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X _LeftClaw: jsr FuncA_Objects_MoveShapeLeftOneTile ; preserves X - jsr FuncA_Objects_Alloc1x1Shape ; preserves X; returns C and Y - bcs @done - txa ; tile ID - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjMachineLight - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @done: - rts + txa ; param: tile ID + ldy #kPaletteObjMachineLight ; param: object flags + jmp FuncA_Objects_Draw1x1Shape .ENDPROC ;;; Draw implemention for trolley machines. @@ -249,13 +239,9 @@ _DrawRope: jsr FuncA_Objects_MoveShapeRightByA ; preserves X @loop: jsr FuncA_Objects_MoveShapeUpOneTile ; preserves X - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns C and Y - bcs @continue - lda #kTileIdObjCraneRope - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjRope - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: + lda #kTileIdObjCraneRope ; param: tile ID + ldy #kPaletteObjRope ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X, returns C and Y dex bne @loop _Return: @@ -276,13 +262,9 @@ _Return: jsr FuncA_Objects_MoveShapeRightByA ; preserves X @loop: jsr FuncA_Objects_MoveShapeDownOneTile ; preserves X - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns C and Y - bcs @continue - lda #kTileIdObjTrolleyRope - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjRope - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: + lda #kTileIdObjTrolleyRope ; param: tile ID + ldy #kPaletteObjRope ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X dex bne @loop rts diff --git a/src/oam.asm b/src/oam.asm index 431464e9..edd84610 100644 --- a/src/oam.asm +++ b/src/oam.asm @@ -272,7 +272,6 @@ Ram_Oam_sObj_arr64: .res .sizeof(sObj) * kNumOamSlots ;;; @return C Set if no OAM slot was allocated, cleared otherwise. ;;; @return Y The OAM byte offset for the allocated object. ;;; @preserve X, T0+ -.EXPORT FuncA_Objects_Alloc1x1Shape .PROC FuncA_Objects_Alloc1x1Shape ;; If the shape is offscreen horizontally, return without allocating any ;; objects. diff --git a/src/platforms/girder.asm b/src/platforms/girder.asm index 305237ae..6940992b 100644 --- a/src/platforms/girder.asm +++ b/src/platforms/girder.asm @@ -18,13 +18,11 @@ ;;;=========================================================================;;; .INCLUDE "../macros.inc" -.INCLUDE "../oam.inc" .INCLUDE "../ppu.inc" -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeRightOneTile .IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft -.IMPORT Ram_Oam_sObj_arr64 .IMPORT Ram_PlatformLeft_i16_0_arr .IMPORT Ram_PlatformRight_i16_0_arr @@ -59,13 +57,9 @@ kTileIdObjGirder = $04 @loop: jsr FuncA_Objects_MoveShapeRightOneTile ; preserves X @startLoop: - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns C and Y - bcs @continue - lda #kTileIdObjGirder - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjGirder - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: + lda #kTileIdObjGirder ; param: tile ID + ldy #kPaletteObjGirder ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X dex bne @loop rts diff --git a/src/rooms/mermaid_spring.asm b/src/rooms/mermaid_spring.asm index 0bf90c4c..d2f11aed 100644 --- a/src/rooms/mermaid_spring.asm +++ b/src/rooms/mermaid_spring.asm @@ -43,7 +43,7 @@ .IMPORT FuncA_Machine_Error .IMPORT FuncA_Machine_GenericTryMoveY .IMPORT FuncA_Machine_PumpTick -.IMPORT FuncA_Objects_Alloc1x1Shape +.IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_DrawMonitorPlatform .IMPORT FuncA_Objects_DrawPumpMachine .IMPORT FuncA_Objects_DrawRocksPlatformHorz @@ -66,7 +66,6 @@ .IMPORT Ram_DeviceType_eDevice_arr .IMPORT Ram_MachineGoalVert_u8_arr .IMPORT Ram_MachineStatus_eMachine_arr -.IMPORT Ram_Oam_sObj_arr64 .IMPORT Ram_PlatformLeft_i16_0_arr .IMPORT Ram_PlatformLeft_i16_1_arr .IMPORT Ram_PlatformTop_i16_0_arr @@ -315,17 +314,13 @@ _Water: ;; Determine the width of the water in tiles, and draw that many objects. ldx _WaterWidth_u8_arr, y @loop: - jsr FuncA_Objects_Alloc1x1Shape ; preserves X, returns C and Y - bcs @continue lda Zp_FrameCounter_u8 div #8 - and #$03 - .assert kTileIdObjPlatformHotSpringFirst & $03 = 0, error - ora #kTileIdObjPlatformHotSpringFirst - sta Ram_Oam_sObj_arr64 + sObj::Tile_u8, y - lda #kPaletteObjHotSpring | bObj::Pri - sta Ram_Oam_sObj_arr64 + sObj::Flags_bObj, y - @continue: + mod #4 + .assert kTileIdObjPlatformHotSpringFirst .mod 4 = 0, error + ora #kTileIdObjPlatformHotSpringFirst ; param: tile ID + ldy #kPaletteObjHotSpring | bObj::Pri ; param: object flags + jsr FuncA_Objects_Draw1x1Shape ; preserves X jsr FuncA_Objects_MoveShapeRightOneTile ; preserves X dex bne @loop