Skip to content

Commit

Permalink
update fix, palette, ram_bios; add animation and collision
Browse files Browse the repository at this point in the history
  • Loading branch information
freem committed Jun 12, 2014
1 parent 7f8f498 commit 5904c78
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 15 deletions.
46 changes: 46 additions & 0 deletions src/inc/animation.inc
@@ -0,0 +1,46 @@
; freemlib for Neo-Geo - Animation Functions
;==============================================================================;
; Animation functions rely on the sprite functions, so be sure to include those.
; The high concept of an animation is a number of frames, with each frame played
; back at a certain speed. We bend this to include collision data as well,
; because video games.
;==============================================================================;
; (Animation Data)
; $00 (word) Primary ID/"Category"
; $02 (word) Secondary ID/"Action" or "State"
; $04 (byte) Tertiary ID
; $05 (byte) Number of Frames in Animation
; $06 (long) Pointer to first Animation Frame Data
;------------------------------------------------------------------------------;
; (Animation Frame Data)
; $00 (word) Number of frames to display frame (60 frames = 1 sec)
; $02 (long) Metasprite pointer for this frame
; $06 (word) Anchor Point X
; $08 (word) Anchor Point Y
; $0A (long) Pointer to Collision Data (see doc/collision.txt)
; $0E (long) Pointer to next displayed frame ($FFFFFFFF if none)
;==============================================================================;
; animmac_AnimData
; Store Animation Data in the binary.

animmac_AnimData: macro
dc.w \1 ; (word) Primary ID/"Category"
dc.w \2 ; (word) Secondary ID/"Action" or "State"
dc.b \3 ; (byte) Tertiary ID (leave 0 if not using)
dc.b \4 ; (byte) Number of frames in Animation
dc.l \5 ; (long) Pointer to first Animation Frame Data
endm

;==============================================================================;
; animmac_AnimFrameData
; Store Animation Frame Data in the binary.

animmac_AnimFrameData: macro
dc.w \1 ; (word) Number of frames to display frame
dc.l \2 ; (long) Metasprite Pointer for this frame
dc.w \3 ; (word) Anchor Point X
dc.w \4 ; (word) Anchor Point Y
dc.l \5 ; (long) Pointer to Collision Data
dc.l \6 ; (long) Pointer to next displayed frame
endm
;==============================================================================;
22 changes: 22 additions & 0 deletions src/inc/collision.inc
@@ -0,0 +1,22 @@
; freemlib for Neo-Geo - Collision Functions
;==============================================================================;
; Collision data is tied to Animation data.
; There are two types of collision boxes, "normal" and "attack".
;==============================================================================;
; collmac_CollisionBoxData
; Writes Collision Box data into the binary.

; \1 Collision Type (word; 0=normal, 1=attack)
; \2 Box X1 (word; start)
; \3 Box Y1 (word; start)
; \4 Box X2 (word; end)
; \5 Box Y2 (word; end)

collmac_CollisionBoxData: macro
dc.w (\1)&1
dc.w \2
dc.w \3
dc.w \4
dc.w \5
endm
;==============================================================================;
58 changes: 52 additions & 6 deletions src/inc/fix.inc
Expand Up @@ -74,7 +74,6 @@ fix_ChangeTile:
fixmac_CalcVRAMAddr ; VRAM address check/combined cell loc. conversion

move.w d0,LSPC_ADDR ; set vram address
move.w #0,LSPC_INCR ; don't increment VRAM address automatically
move.w LSPC_DATA,d2 ; get current data
andi.w #$F000,d2 ; mask for palette
or.w d2,d1 ; OR with new tile data
Expand All @@ -93,7 +92,6 @@ fix_ChangePal:
fixmac_CalcVRAMAddr ; VRAM address check/combined cell loc. conversion

move.w d0,LSPC_ADDR ; set vram address
move.w #0,LSPC_INCR ; don't increment VRAM address automatically
move.w LSPC_DATA,d2 ; get current data
andi.w #$0FFF,d2 ; mask for tile index
or.w d2,d1 ; OR with new palette
Expand All @@ -112,7 +110,19 @@ fix_ChangePal:
fix_Draw8x16:
fixmac_CalcVRAMAddr ; VRAM address check/combined cell loc. conversion

.fix_d8x16Loop:
move.w #$20,LSPC_INCR ; set VRAM increment +$20 (horiz. writing)

; draw top line
.fix_d8x16_TopLoop:


; prepare to draw bottom line
; (change VRAM address, reset loop vars)

; draw bottom line
.fix_d8x16_BotLoop:


rts

;==============================================================================;
Expand All @@ -127,7 +137,18 @@ fix_Draw8x16:
fix_Draw16x16:
fixmac_CalcVRAMAddr ; VRAM address check/combined cell loc. conversion

.fix_d16x16Loop:
move.w #$20,LSPC_INCR ; set VRAM increment +$20 (horiz. writing)

; draw top line
.fix_d16x16_TopLoop:


; prepare to draw bottom line
; (change VRAM address, reset loop vars)

; draw bottom line
.fix_d16x16_BotLoop:

rts

;==============================================================================;
Expand All @@ -136,8 +157,8 @@ fix_Draw16x16:

; (Params)
; d0 Combined cell location (x,y) or Raw VRAM address ($7000-$74FF)
; d? Combined rows/columns size
; d? Palette index and tile number MSB
; d1 Combined rows/columns size ($XXYY)
; d2 Palette index and tile number MSB
; a0 Pointer to data to draw

; (Clobbers)
Expand All @@ -147,8 +168,33 @@ fix_Draw16x16:
fix_DrawRegion:
fixmac_CalcVRAMAddr ; VRAM address check/combined cell loc. conversion

move.w #$20,LSPC_INCR ; set VRAM increment +$20 (horiz. writing)
move.w d0,LSPC_ADDR ; set initial VRAM address

; get rows
move.w d1,d7
andi.w #$FF00,d7
lsr.w #8,d7 ; shift right

; loop 1 (row/Y)
fix_DrawRegion_Rows:
; get cols
move.w d1,d6
andi.w #$00FF,d6

; loop 2 (column/X)
fix_DrawRegion_Cols:
; write data
move.w (a0)+,LSPC_DATA
; loop cols
dbra d6,fix_DrawRegion_Cols

; update vram address
addi.w #$20,d0
move.w d0,LSPC_ADDR

; loop rows
dbra d7,fix_DrawRegion_Rows

fix_DrawRegion_End:
rts
11 changes: 10 additions & 1 deletion src/inc/palette.inc
Expand Up @@ -67,6 +67,7 @@ palmac_LoadData: macro

pal_LoadBuf:
; todo: load data into PaletteBuffer
;lea PaletteBuffer+d6,a1
rts

; palmac_LoadBuf
Expand Down Expand Up @@ -111,7 +112,6 @@ pal_LoadSet:
pal_SetColor:
palmac_PalBufIndex ; get address in palette buffer
move.w d6,(a0) ; write new color value

rts

;==============================================================================;
Expand Down Expand Up @@ -166,7 +166,10 @@ pal_SetSingleRed:
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value

; deconstruct passed Red channel value into palette Red
; change Red

move.w d5,(a0) ; update color value

rts
Expand All @@ -183,7 +186,10 @@ pal_SetSingleGreen:
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value

; deconstruct passed Green channel value into palette Green
; change Green

move.w d5,(a0) ; update color value

rts
Expand All @@ -200,7 +206,10 @@ pal_SetSingleBlue:
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value

; deconstruct passed Blue channel value into palette Blue
; change Blue

move.w d5,(a0) ; update color value

rts
16 changes: 8 additions & 8 deletions src/inc/ram_bios.inc
Expand Up @@ -113,7 +113,7 @@ BIOS_PLAYER4_MODE equ $10FDB9 ; (byte) Player 4 Status
; Status Values: 0=No play, 1=Playing, 2=Continue display, 3=Game Over
;-----------------------------------;
;??? equ $10FDBA ; (long)
BIOS_MESS_POINT equ $10FDBE ; (dword) pointer to buffer
BIOS_MESS_POINT equ $10FDBE ; (long) pointer to buffer
BIOS_MESS_BUSY equ $10FDC2 ; (word) 0=run MESS_OUT, 1=skip MESS_OUT
;-----------------------------------;
BIOS_CARD_COMMAND equ $10FDC4 ; (byte) Command to execute
Expand All @@ -125,13 +125,13 @@ BIOS_CARD_FCB equ $10FDCE ; (word) Game NGH number
BIOS_CARD_SUB equ $10FDD0 ; (byte/word) Game sub number (0-15)
;-----------------------------------;
; DATE_TIME
BIOS_YEAR equ $10FDD2
BIOS_MONTH equ $10FDD3
BIOS_DAY equ $10FDD4
BIOS_WEEKDAY equ $10FDD5
BIOS_HOUR equ $10FDD6
BIOS_MINUTE equ $10FDD7
BIOS_SECOND equ $10FDD8
BIOS_YEAR equ $10FDD2 ; (byte)
BIOS_MONTH equ $10FDD3 ; (byte)
BIOS_DAY equ $10FDD4 ; (byte)
BIOS_WEEKDAY equ $10FDD5 ; (byte)
BIOS_HOUR equ $10FDD6 ; (byte)
BIOS_MINUTE equ $10FDD7 ; (byte)
BIOS_SECOND equ $10FDD8 ; (byte)
;-----------------------------------;
BIOS_SELECT_TIMER equ $10FDDA ; (byte) "BIOS_COMPULSION_TIMER"
;BIOS_START_TEST equ $10FDDC ; ()
Expand Down

0 comments on commit 5904c78

Please sign in to comment.