Added inventory tabs and number rendering

This commit is contained in:
blondie7575 2018-06-10 13:00:05 -06:00
parent 4edd8540f5
commit cfeefce8c3
14 changed files with 202 additions and 11 deletions

Binary file not shown.

BIN
Art/Tab_007.xcf Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 197 B

BIN
Art/tab_007.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

View File

@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
7002647320CD78C40015B184 /* smallNumbers.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = smallNumbers.s; sourceTree = "<group>"; };
700B5E6F2069831000B31C00 /* inventory.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = inventory.s; sourceTree = "<group>"; }; 700B5E6F2069831000B31C00 /* inventory.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = inventory.s; sourceTree = "<group>"; };
700C39C51F2E5CA800C24F9C /* tables.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = tables.s; sourceTree = "<group>"; }; 700C39C51F2E5CA800C24F9C /* tables.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = tables.s; sourceTree = "<group>"; };
700F21DE1F43E31300D7007D /* input.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = input.s; sourceTree = "<group>"; }; 700F21DE1F43E31300D7007D /* input.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = input.s; sourceTree = "<group>"; };
@ -48,6 +49,7 @@
7099E3841F41022100182A82 /* gameobject.s */, 7099E3841F41022100182A82 /* gameobject.s */,
706DF1641F2D39F700AA6680 /* loader.s */, 706DF1641F2D39F700AA6680 /* loader.s */,
700FFAFB1F40F3BF00A442DE /* font.s */, 700FFAFB1F40F3BF00A442DE /* font.s */,
7002647320CD78C40015B184 /* smallNumbers.s */,
706DF1651F2D4A8100AA6680 /* terrain.s */, 706DF1651F2D4A8100AA6680 /* terrain.s */,
705AAFA920040B0D001BB0ED /* terrain_e1.s */, 705AAFA920040B0D001BB0ED /* terrain_e1.s */,
70C073091F5BAA3E009844A9 /* collision.s */, 70C073091F5BAA3E009844A9 /* collision.s */,

View File

@ -16,7 +16,7 @@ ADDR=800
PGM=gscats PGM=gscats
MRSPRITE=../MrSprite/mrsprite MRSPRITE=../MrSprite/mrsprite
CHROMA=a4dffb CHROMA=a4dffb
PALETTE=a4dffb a4dffb 008800 886611 cc9933 eebb44 dd6666 ff99aa 00ff00 ff0000 b7b7b7 dddddd 0077bb ffff00 000000 ffffff PALETTE=a4dffb a4dffb 008800 886611 cc9933 eebb44 dd6666 ff99aa 777777 ff0000 b7b7b7 dddddd 0077bb ffff00 000000 ffffff
SPRITES=SpriteBank SPRITES=SpriteBank
REMOTESYMBOLS=-Wl $(shell ./ParseMapFile.py *.map) REMOTESYMBOLS=-Wl $(shell ./ParseMapFile.py *.map)

Binary file not shown.

View File

@ -335,7 +335,7 @@ fire:
basePalette: basePalette:
; Color 0 and 1 must both be sky blue. Compiled rendering uses PHD (which must contain $0000), ; Color 0 and 1 must both be sky blue. Compiled rendering uses PHD (which must contain $0000),
; and span rendering uses fill mode, so 0 can't be used there ; and span rendering uses fill mode, so 0 can't be used there
.word $0aef,$0aef,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$00f0,$0f00,$0bbb,$ddd,$007b,$0ff0,$0000,$0fff .word $0aef,$0aef,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0777,$0f00,$0bbb,$ddd,$007b,$0ff0,$0000,$0fff
statusBarPalette: statusBarPalette:
.word $0888,$0aef,$0F00,$0861,$0c93,$0eb4,$0d66,$0f9a,$00f0,$0fff,$0bbb,$ddd,$007b,$0000,$0ff0,$0fff .word $0888,$0aef,$0F00,$0861,$0c93,$0eb4,$0d66,$0f9a,$00f0,$0fff,$0bbb,$ddd,$007b,$0000,$0ff0,$0fff

Binary file not shown.

View File

@ -37,6 +37,7 @@ quitGame:
.include "graphics.s" .include "graphics.s"
.include "font.s" .include "font.s"
.include "smallNumbers.s"
.include "player.s" .include "player.s"
.include "terrain.s" .include "terrain.s"
.include "collision.s" .include "collision.s"

View File

@ -8,9 +8,11 @@
INVENTORY_ITEMS = 2 INVENTORY_ITEMS = 2
ITEM_WIDTH = 16 ; In pixels ITEM_WIDTH = 16 ; In pixels
ITEM_HEIGHT = 16 ; In pixels
ICON_WIDTH = 8 ; In pixels ICON_WIDTH = 8 ; In pixels
ICON_ORIGIN = (ITEM_WIDTH-ICON_WIDTH)/4 ; In bytes ICON_ORIGIN = (ITEM_WIDTH-ICON_WIDTH)/4 ; In bytes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderInventory ; renderInventory
; ;
@ -25,9 +27,9 @@ renderInventory:
ldy currentPlayer ldy currentPlayer
PLAYERPTR_Y PLAYERPTR_Y
lda playerData+PD_INVENTORY,y lda playerData+PD_INVENTORY,y
sta PARAML0 sta PARAML1
; Compute initial VRAM position ; Compute initial VRAM position ($E1-relative)
ldy #(8192 + (160*10 + (160*ICON_ORIGIN + ICON_ORIGIN))) ldy #(8192 + (160*10 + (160*ICON_ORIGIN + ICON_ORIGIN)))
ldx #0 ldx #0
@ -52,8 +54,8 @@ RESTORE_AXY
; renderInventoryItem ; renderInventoryItem
; ;
; X = Item index ; X = Item index
; Y = VRAM pos ; Y = VRAM pos ($E1-relative)
; PARAML0 = Inventory state ; PARAML1 = Inventory state
; ;
renderInventoryItem: renderInventoryItem:
SAVE_AXY SAVE_AXY
@ -63,18 +65,40 @@ renderInventoryItem:
lda #2 ; Frame lda #2 ; Frame
clc clc
jsr DrawSpriteBank jsr DrawSpriteBank
plx
; Find projectile type data ; Find projectile type data
txy ply ; Pushed as X
PROJECTILETYPEPTR_Y PROJECTILETYPEPTR_Y
; Render projectile ; Render projectile
lda projectileTypes+PT_FRAME1,y lda projectileTypes+PT_FRAME1,y
ply ply
phy
clc clc
jsr DrawSpriteBank jsr DrawSpriteBank
; Render counter background
clc
pla
adc #ITEM_HEIGHT*160
pha
tay
lda #7
jsr DrawSpriteBank
; Render counter
lda #789
sta PARAML0
jsr intToString
sec
pla
sbc #($2000 - 160*2)-1 ; Font engine wants VRAM-relative
tax
lda #intToStringResult
jsr DrawNumber
RESTORE_AXY RESTORE_AXY
rts rts

View File

@ -165,6 +165,10 @@
.dbyt (Arg>>16)&$7777,Arg&$00007777 .dbyt (Arg>>16)&$7777,Arg&$00007777
.endmacro .endmacro
.macro fontword Arg ; Converts 0->A,F->E to match our palette for font rendering
.dbyt (((Arg & $FF00) | $AA00) & $EE00) | (((Arg & $00FF) | $00AA) & $00EE)
.endmacro
.macro BREAK .macro BREAK
pha pha
lda breakpoint lda breakpoint

160
smallNumbers.s Normal file
View File

@ -0,0 +1,160 @@
; Mini font render dedicated to small numbers.
; Adapted from Dagen Brock's general purpose font
; engine, also in this project
;
; A= ptr to string preceded by length
; X= screen location
; Trashes zero page locations 6,7
;
F_LEN: .word 0 ;length of string (only one byte currently used)
F_DIGITIDX: .word 0 ;index of current character
F_CURRPOS: .word 0 ;current top left char position
F_NUMPTR = $06 ;pointer to string (including length byte) / DP
DrawNumber:
SAVE_AXY
sta F_NUMPTR
stx F_CURRPOS
stz F_DIGITIDX
lda (F_NUMPTR)
and #$00ff ;strip off first char (len is only one byte)
sta F_LEN ;get our length byte
nextDigit:
lda F_DIGITIDX
cmp F_LEN
bne moreDigits
RESTORE_AXY
rts
moreDigits:
inc F_DIGITIDX
ldy F_DIGITIDX
lda (F_NUMPTR),y ;get next char!
and #$00FF ;mask high byte
sec
sbc #'0' ;our table starts with space ' '
asl
tay
ldx F_CURRPOS
jsr drawDigit
inc F_CURRPOS
inc F_CURRPOS ;update screen pos (1 word=4 pixels)
bra nextDigit
;x = TopLeft screen pos
;y = char table offset
drawDigit:
lda DigitTable,y ;get real address of char data
sec
sbc #DigitData ;pivot offset - now a is offset of fontdata
tay ;so we'll index with that
lda DigitData,y
sta $012000,x
lda DigitData+2,y
sta $012000+160,x
lda DigitData+4,y
sta $012000+160*2,x
lda DigitData+6,y
sta $012000+160*3,x
lda DigitData+8,y
sta $012000+160*4,x
rts
DigitTable:
.addr s_0
.addr s_1
.addr s_2
.addr s_3
.addr s_4
.addr s_5
.addr s_6
.addr s_7
.addr s_8
.addr s_9
DigitData:
s_0:
fontword $FFF0
fontword $F0F0
fontword $F0F0
fontword $F0F0
fontword $FFF0
s_1:
fontword $0F00
fontword $FF00
fontword $0F00
fontword $0F00
fontword $0F00
s_2:
fontword $FFF0
fontword $00F0
fontword $FFF0
fontword $F000
fontword $FFF0
s_3:
fontword $FFF0
fontword $00F0
fontword $FFF0
fontword $00F0
fontword $FFF0
s_4:
fontword $F0F0
fontword $F0F0
fontword $FFF0
fontword $00F0
fontword $00F0
s_5:
fontword $FFF0
fontword $F000
fontword $FFF0
fontword $00F0
fontword $FFF0
s_6:
fontword $FFF0
fontword $F000
fontword $FFF0
fontword $F0F0
fontword $FFF0
s_7:
fontword $FFF0
fontword $00F0
fontword $00F0
fontword $00F0
fontword $00F0
s_8:
fontword $FFF0
fontword $F0F0
fontword $FFF0
fontword $F0F0
fontword $FFF0
s_9:
fontword $FFF0
fontword $F0F0
fontword $FFF0
fontword $00F0
fontword $00F0

View File

@ -2,16 +2,16 @@
DrawSpriteBank : DrawSpriteBank :
ASL ; A=Sprite Number ($0000-$0006) ASL ; A=Sprite Number ($0000-$0007)
TAX ; Y=Target Screen Address ($2000-$9D00) TAX ; Y=Target Screen Address ($2000-$9D00)
LDA SpriteBankNum,X ; Relative Sprite Number Table LDA SpriteBankNum,X ; Relative Sprite Number Table
JMP (SpriteBankBank,X) ; Bank Number Table JMP (SpriteBankBank,X) ; Bank Number Table
SpriteBankNum : SpriteBankNum :
.dbyt $0100,$0000,$0500,$0200,$0300,$0600,$0400 .dbyt $0100,$0000,$0500,$0200,$0300,$0700,$0400,$0600
SpriteBankBank : SpriteBankBank :
.addr SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00 .addr SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00,SpriteBankBank00
SpriteBankBank00 : SpriteBankBank00 :
JSL $AA0000 JSL $AA0000