diff --git a/GSCats.xcodeproj/project.pbxproj b/GSCats.xcodeproj/project.pbxproj index 4f954b3..096eb84 100644 --- a/GSCats.xcodeproj/project.pbxproj +++ b/GSCats.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXFileReference section */ 700C39C51F2E5CA800C24F9C /* tables.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = tables.s; sourceTree = ""; }; 700F21DE1F43E31300D7007D /* input.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = input.s; sourceTree = ""; }; + 700F21DF1F4A364600D7007D /* projectile.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = projectile.s; sourceTree = ""; }; + 700F21E01F4A3A5500D7007D /* GenerateTrigTables.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateTrigTables.py; sourceTree = ""; }; 700FFAFB1F40F3BF00A442DE /* font.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = font.s; sourceTree = ""; }; 7059502B1F37A0BE00BBE90F /* GenerateVRAMTable.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateVRAMTable.py; sourceTree = ""; }; 706DF1641F2D39F700AA6680 /* loader.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = loader.s; sourceTree = ""; }; @@ -41,12 +43,14 @@ 70F086A01F4230CB002446C3 /* utility.s */, 700C39C51F2E5CA800C24F9C /* tables.s */, 70F0869F1F413A89002446C3 /* player.s */, + 700F21DF1F4A364600D7007D /* projectile.s */, 70A80FB01F43D7F200BD34C9 /* gamemanager.s */, 70E9D8611F2BD95400555C19 /* gscats.s */, 70E9D8631F2BD95400555C19 /* Makefile */, 7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */, 7059502B1F37A0BE00BBE90F /* GenerateVRAMTable.py */, 7099E3851F4107B100182A82 /* GenerateVRAMYOffset.py */, + 700F21E01F4A3A5500D7007D /* GenerateTrigTables.py */, ); sourceTree = ""; }; diff --git a/GenerateTrigTables.py b/GenerateTrigTables.py new file mode 100755 index 0000000..5dde14a --- /dev/null +++ b/GenerateTrigTables.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import sys +import math + + +def main(argv): + + # Prologue + print ("sineTable:",end="") + rowCount = 7 + + for v in range(0,512): + rowCount += 1 + if (rowCount==8): + print ("\n\t.word ", end="") + rowCount=0 + + print ("$%04x" % (int)(math.sin((2*3.14159)/512 * v)*256+256), end="") + if (rowCount<7): + print (",", end="") + + +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/gscats.2mg b/gscats.2mg index 69fce4f..c36176a 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/gscats.s b/gscats.s index 54a1ad2..f63edc2 100644 --- a/gscats.s +++ b/gscats.s @@ -37,6 +37,7 @@ quitGame: .include "tables.s" .include "gamemanager.s" .include "input.s" +.include "projectile.s" endMainBank2: diff --git a/player.s b/player.s index 919492d..2791a83 100644 --- a/player.s +++ b/player.s @@ -15,7 +15,7 @@ playerData: .word 50 ; Power PD_ANGLE = 4 ; Byte offsets into player data structure -PD_POS = 6 +PD_POWER = 6 .macro PLAYERPTR_Y tya ; Pointer to player structure from index @@ -85,8 +85,20 @@ renderPlayerHeader: ldx #24 jsr drawNumber + ldx #48 + lda #powerStr + jsr DrawString + + lda playerData+PD_POWER,y + ldx #72 + jsr drawNumber + RESTORE_AXY rts angleStr: pstring "ANGLE: " +powerStr: + pstring "POWER: " + + diff --git a/projectile.s b/projectile.s new file mode 100644 index 0000000..0e575ec --- /dev/null +++ b/projectile.s @@ -0,0 +1,58 @@ +; +; projectile +; Code and data structures related to the projectiles +; +; Created by Quinn Dunki on 8/13/17 +; + + +projectileData: + ; gameobject data + .word 40 ; X pos in pixels (from left terrain edge) + .word 38 ; Y pos in pixels (from bottom terrain edge) + + .word 0 ; Velocity (8.8 fixed point) + +JD_V = 4 ; Byte offsets into projectile data structure + + +projectileParams: + .word 0 ; Starting pos X + .word 0 ; Starting pos Y + .word 0 ; Initial angle + .word 0 ; Initial power + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; fireProjectile +; +; PARAML0 = Pointer to projectileParams +; +; Trashes SCRATCHL +; +fireProjectile: + SAVE_AXY + + ; Set up projectile structure + ldy #0 + ldx #0 + lda #projectileData ; Only one active at a tiem for now + sta SCRATCHL + +; lda (PARAML0),x ; X pos +; sta (SCRATCHL),y +; inx +; inx +; iny +; iny +; lda (PARAML0),x ; Y pos +; sta (SCRATCHL),y +; inx +; inx +; lda (PARAML0),x ; + +fireProjectileLoop: + + + RESTORE_AXY + rts diff --git a/tables.s b/tables.s index ee4f3ec..3008950 100644 --- a/tables.s +++ b/tables.s @@ -1,36 +1,68 @@ sineTable: - .byte $80, $83, $86, $89, $8C, $90, $93, $96 - .byte $99, $9C, $9F, $A2, $A5, $A8, $AB, $AE - .byte $B1, $B3, $B6, $B9, $BC, $BF, $C1, $C4 - .byte $C7, $C9, $CC, $CE, $D1, $D3, $D5, $D8 - .byte $DA, $DC, $DE, $E0, $E2, $E4, $E6, $E8 - .byte $EA, $EB, $ED, $EF, $F0, $F1, $F3, $F4 - .byte $F5, $F6, $F8, $F9, $FA, $FA, $FB, $FC - .byte $FD, $FD, $FE, $FE, $FE, $FF, $FF, $FF - .byte $FF, $FF, $FF, $FF, $FE, $FE, $FE, $FD - .byte $FD, $FC, $FB, $FA, $FA, $F9, $F8, $F6 - .byte $F5, $F4, $F3, $F1, $F0, $EF, $ED, $EB - .byte $EA, $E8, $E6, $E4, $E2, $E0, $DE, $DC - .byte $DA, $D8, $D5, $D3, $D1, $CE, $CC, $C9 - .byte $C7, $C4, $C1, $BF, $BC, $B9, $B6, $B3 - .byte $B1, $AE, $AB, $A8, $A5, $A2, $9F, $9C - .byte $99, $96, $93, $90, $8C, $89, $86, $83 - .byte $80, $7D, $7A, $77, $74, $70, $6D, $6A - .byte $67, $64, $61, $5E, $5B, $58, $55, $52 - .byte $4F, $4D, $4A, $47, $44, $41, $3F, $3C - .byte $39, $37, $34, $32, $2F, $2D, $2B, $28 - .byte $26, $24, $22, $20, $1E, $1C, $1A, $18 - .byte $16, $15, $13, $11, $10, $0F, $0D, $0C - .byte $0B, $0A, $08, $07, $06, $06, $05, $04 - .byte $03, $03, $02, $02, $02, $01, $01, $01 - .byte $01, $01, $01, $01, $02, $02, $02, $03 - .byte $03, $04, $05, $06, $06, $07, $08, $0A - .byte $0B, $0C, $0D, $0F, $10, $11, $13, $15 - .byte $16, $18, $1A, $1C, $1E, $20, $22, $24 - .byte $26, $28, $2B, $2D, $2F, $32, $34, $37 - .byte $39, $3C, $3F, $41, $44, $47, $4A, $4D - .byte $4F, $52, $55, $58, $5B, $5E, $61, $64 - .byte $67, $6A, $6D, $70, $74, $77, $7A, $7D, $80 ; One byte wrap for easier 16-byte sampling + .word $0100,$0103,$0106,$0109,$010c,$010f,$0112,$0115 + .word $0119,$011c,$011f,$0122,$0125,$0128,$012b,$012e + .word $0131,$0135,$0138,$013b,$013e,$0141,$0144,$0147 + .word $014a,$014d,$0150,$0153,$0156,$0159,$015c,$015f + .word $0161,$0164,$0167,$016a,$016d,$0170,$0173,$0175 + .word $0178,$017b,$017e,$0180,$0183,$0186,$0188,$018b + .word $018e,$0190,$0193,$0195,$0198,$019b,$019d,$019f + .word $01a2,$01a4,$01a7,$01a9,$01ab,$01ae,$01b0,$01b2 + .word $01b5,$01b7,$01b9,$01bb,$01bd,$01bf,$01c1,$01c3 + .word $01c5,$01c7,$01c9,$01cb,$01cd,$01cf,$01d1,$01d3 + .word $01d4,$01d6,$01d8,$01d9,$01db,$01dd,$01de,$01e0 + .word $01e1,$01e3,$01e4,$01e6,$01e7,$01e8,$01ea,$01eb + .word $01ec,$01ed,$01ee,$01ef,$01f1,$01f2,$01f3,$01f4 + .word $01f4,$01f5,$01f6,$01f7,$01f8,$01f9,$01f9,$01fa + .word $01fb,$01fb,$01fc,$01fc,$01fd,$01fd,$01fe,$01fe + .word $01fe,$01ff,$01ff,$01ff,$01ff,$01ff,$01ff,$01ff + .word $01ff,$01ff,$01ff,$01ff,$01ff,$01ff,$01ff,$01ff + .word $01fe,$01fe,$01fe,$01fd,$01fd,$01fc,$01fc,$01fb + .word $01fb,$01fa,$01f9,$01f9,$01f8,$01f7,$01f6,$01f5 + .word $01f4,$01f4,$01f3,$01f2,$01f1,$01ef,$01ee,$01ed + .word $01ec,$01eb,$01ea,$01e8,$01e7,$01e6,$01e4,$01e3 + .word $01e1,$01e0,$01de,$01dd,$01db,$01d9,$01d8,$01d6 + .word $01d4,$01d3,$01d1,$01cf,$01cd,$01cb,$01c9,$01c7 + .word $01c5,$01c3,$01c1,$01bf,$01bd,$01bb,$01b9,$01b7 + .word $01b5,$01b2,$01b0,$01ae,$01ab,$01a9,$01a7,$01a4 + .word $01a2,$019f,$019d,$019b,$0198,$0195,$0193,$0190 + .word $018e,$018b,$0188,$0186,$0183,$0180,$017e,$017b + .word $0178,$0175,$0173,$0170,$016d,$016a,$0167,$0164 + .word $0161,$015f,$015c,$0159,$0156,$0153,$0150,$014d + .word $014a,$0147,$0144,$0141,$013e,$013b,$0138,$0135 + .word $0131,$012e,$012b,$0128,$0125,$0122,$011f,$011c + .word $0119,$0115,$0112,$010f,$010c,$0109,$0106,$0103 + .word $0100,$00fc,$00f9,$00f6,$00f3,$00f0,$00ed,$00ea + .word $00e6,$00e3,$00e0,$00dd,$00da,$00d7,$00d4,$00d1 + .word $00ce,$00ca,$00c7,$00c4,$00c1,$00be,$00bb,$00b8 + .word $00b5,$00b2,$00af,$00ac,$00a9,$00a6,$00a3,$00a0 + .word $009e,$009b,$0098,$0095,$0092,$008f,$008c,$008a + .word $0087,$0084,$0081,$007f,$007c,$0079,$0077,$0074 + .word $0071,$006f,$006c,$006a,$0067,$0064,$0062,$0060 + .word $005d,$005b,$0058,$0056,$0054,$0051,$004f,$004d + .word $004a,$0048,$0046,$0044,$0042,$0040,$003e,$003c + .word $003a,$0038,$0036,$0034,$0032,$0030,$002e,$002c + .word $002b,$0029,$0027,$0026,$0024,$0022,$0021,$001f + .word $001e,$001c,$001b,$0019,$0018,$0017,$0015,$0014 + .word $0013,$0012,$0011,$0010,$000e,$000d,$000c,$000b + .word $000b,$000a,$0009,$0008,$0007,$0006,$0006,$0005 + .word $0004,$0004,$0003,$0003,$0002,$0002,$0001,$0001 + .word $0001,$0000,$0000,$0000,$0000,$0000,$0000,$0000 + .word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 + .word $0001,$0001,$0001,$0002,$0002,$0003,$0003,$0004 + .word $0004,$0005,$0006,$0006,$0007,$0008,$0009,$000a + .word $000b,$000b,$000c,$000d,$000e,$0010,$0011,$0012 + .word $0013,$0014,$0015,$0017,$0018,$0019,$001b,$001c + .word $001e,$001f,$0021,$0022,$0024,$0026,$0027,$0029 + .word $002b,$002c,$002e,$0030,$0032,$0034,$0036,$0038 + .word $003a,$003c,$003e,$0040,$0042,$0044,$0046,$0048 + .word $004a,$004d,$004f,$0051,$0054,$0056,$0058,$005b + .word $005d,$0060,$0062,$0064,$0067,$006a,$006c,$006f + .word $0071,$0074,$0077,$0079,$007c,$007f,$0081,$0084 + .word $0087,$008a,$008c,$008f,$0092,$0095,$0098,$009b + .word $009e,$00a0,$00a3,$00a6,$00a9,$00ac,$00af,$00b2 + .word $00b5,$00b8,$00bb,$00be,$00c1,$00c4,$00c7,$00ca + .word $00ce,$00d1,$00d4,$00d7,$00da,$00dd,$00e0,$00e3 + .word $00e6,$00ea,$00ed,$00f0,$00f3,$00f6,$00f9,$00fc vramRowEndsMinusOne: .word $209f,$213f,$21df,$227f,$231f,$23bf,$245f,$24ff,$259f,$263f,$26df,$277f,$281f,$28bf,$295f,$29ff,$2a9f,$2b3f,$2bdf,$2c7f diff --git a/terrain.s b/terrain.s index e4696bd..f9ae7a1 100644 --- a/terrain.s +++ b/terrain.s @@ -243,14 +243,6 @@ generateTerrainLoop: lda sineTable,x lsr - lsr - lsr - lsr - lsr - lsr - lsr - lsr - lsr lsr @@ -261,11 +253,13 @@ generateTerrainLoop: iny iny - inx - inx - inx + clc txa - and #$00ff + adc #12 + tax + + txa + and #$03ff tax cpy #TERRAINWIDTH/2