From ea808cbf9aee2f50c9926d6e67773da2b29b649b Mon Sep 17 00:00:00 2001 From: blondie7575 Date: Sun, 13 Aug 2017 15:36:12 -0700 Subject: [PATCH] Groundwork for gameobject rendering --- GSCats.xcodeproj/project.pbxproj | 6 ++- GenerateVRAMYOffset.py | 25 ++++++++++ equates.s | 2 +- gameobject.s | 76 +++++++++++++++++++++++++++++++ gscats.2mg | Bin 819264 -> 819264 bytes gscats.s | 21 +++++++-- player.s | 7 --- tables.s | 13 ++++++ 8 files changed, 136 insertions(+), 14 deletions(-) create mode 100755 GenerateVRAMYOffset.py create mode 100644 gameobject.s delete mode 100644 player.s diff --git a/GSCats.xcodeproj/project.pbxproj b/GSCats.xcodeproj/project.pbxproj index 1d59eaf..e451ea9 100644 --- a/GSCats.xcodeproj/project.pbxproj +++ b/GSCats.xcodeproj/project.pbxproj @@ -13,7 +13,8 @@ 706DF1641F2D39F700AA6680 /* loader.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = loader.s; sourceTree = ""; }; 706DF1651F2D4A8100AA6680 /* terrain.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = terrain.s; sourceTree = ""; }; 7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateRenderSpans.py; sourceTree = ""; }; - 7099E3841F41022100182A82 /* player.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = player.s; sourceTree = ""; }; + 7099E3841F41022100182A82 /* gameobject.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameobject.s; sourceTree = ""; }; + 7099E3851F4107B100182A82 /* GenerateVRAMYOffset.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = GenerateVRAMYOffset.py; sourceTree = ""; }; 70E9D85F1F2BD95400555C19 /* equates.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = equates.s; sourceTree = ""; }; 70E9D8601F2BD95400555C19 /* graphics.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = graphics.s; sourceTree = ""; }; 70E9D8611F2BD95400555C19 /* gscats.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gscats.s; sourceTree = ""; }; @@ -28,7 +29,7 @@ 70E9D85F1F2BD95400555C19 /* equates.s */, 70E9D8601F2BD95400555C19 /* graphics.s */, 70E9D8621F2BD95400555C19 /* macros.s */, - 7099E3841F41022100182A82 /* player.s */, + 7099E3841F41022100182A82 /* gameobject.s */, 706DF1641F2D39F700AA6680 /* loader.s */, 700FFAFB1F40F3BF00A442DE /* font.s */, 706DF1651F2D4A8100AA6680 /* terrain.s */, @@ -37,6 +38,7 @@ 70E9D8631F2BD95400555C19 /* Makefile */, 7088096D1F2ECE8D00D4C950 /* GenerateRenderSpans.py */, 7059502B1F37A0BE00BBE90F /* GenerateVRAMTable.py */, + 7099E3851F4107B100182A82 /* GenerateVRAMYOffset.py */, ); sourceTree = ""; }; diff --git a/GenerateVRAMYOffset.py b/GenerateVRAMYOffset.py new file mode 100755 index 0000000..6cfa08e --- /dev/null +++ b/GenerateVRAMYOffset.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import sys + + +def main(argv): + + # Prologue + print ("vramYOffset:",end="") + rowCount = 19 + + for jump in range(0,200): + rowCount += 1 + if (rowCount==20): + print ("\n\t.word ", end="") + rowCount=0 + + print ("$%04x" % (jump*160), end="") + if (rowCount<19): + print (",", end="") + + +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/equates.s b/equates.s index 22eab52..f0cf28c 100644 --- a/equates.s +++ b/equates.s @@ -7,7 +7,7 @@ STACKCTL = $e0c068 KBD = $e0c000 KBDSTROBE = $e0c010 COUT = $fded - +VRAM = $e12000 ; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS) PARAM0 = $06 diff --git a/gameobject.s b/gameobject.s new file mode 100644 index 0000000..337c64f --- /dev/null +++ b/gameobject.s @@ -0,0 +1,76 @@ +; +; gameobject +; Code and data structures related to the game objects +; +; Created by Quinn Dunki on 8/13/17 +; + +GAMEOBJECTWIDTH = 8 +GAMEOBJECTHEIGHT = 8 + + +gameobjectData: + .word 40 ; X pos in pixels (from left terrain edge) + .word 38 ; Y pos in pixels (from bottom terrain edge) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; renderGameobject +; +; PARAML0 = Pointer to gameobject data +; +renderGameobject: + SAVE_AXY + + ; Find gameobject location in video memory + ldy #0 + + ; X + lda (PARAML0),y + lsr + sec + sbc leftScreenEdge + bmi renderGameobjectDone ; Gameobject is off left edge of screen + cmp #320 - GAMEOBJECTWIDTH + bpl renderGameobjectDone ; Gameobject is off right edge of screen + sta SCRATCHL + + ; Y + iny + iny + sec + lda #200 + sbc (PARAML0),y + bmi renderGameobjectDone ; Gameobject is off top edge of screen + cmp #200 - GAMEOBJECTHEIGHT + bpl renderGameobjectDone ; Gameobject is off bottom edge of screen + + asl + tax + lda vramYOffset,x + clc + adc SCRATCHL + tax + + ; X now contains the VRAM offset of the upper left corner + lda #$FFFF + sta VRAM,x + sta VRAM+2,x + sta VRAM+160,x + sta VRAM+160+2,x + sta VRAM+160*2,x + sta VRAM+160*2+2,x + sta VRAM+160*3,x + sta VRAM+160*3+2,x + sta VRAM+160*4,x + sta VRAM+160*4+2,x + sta VRAM+160*5,x + sta VRAM+160*5+2,x + sta VRAM+160*6,x + sta VRAM+160*6+2,x + sta VRAM+160*7,x + sta VRAM+160*7+2,x + +renderGameobjectDone: + RESTORE_AXY + rts diff --git a/gscats.2mg b/gscats.2mg index b6d32bfb1f83210df4f0ad8c092a35602e1595c2..eecd4664456b2ca83b49e9f08b62085b01be2c73 100644 GIT binary patch delta 1581 zcmaKrZEO@p7{}+X-1c^F_inFO;I2TKzEJKc)T8C)EYMDCfdXgWfKrOcSXwE_I|zkh zZXz63!b$7Jq$Zdfs~@`H$xA;#V@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KR=7q8T;mh-e3NCl?csS{ z3RNBQ35zWtyWw`TY`gRQoR`^WS5Kb&`$}yfT&;f@I#>&UWfeDm5ePJs3(e;OpMSGP zCTeC@!x>1y5EBy}?6Ls`?+_Dnc zRYpgUvBs!RLq@P7Wqyi`Zy6m$2B}P$$Bx$Pim4bOTAJ=qSCDNQreUR*(2A= zt#YT_FOSNTQpOZhd8VWln6G226%E%9rQvcy$`I&bJsEkKpcQ*m-;xWKH-O}vWMv_5bjdnyeR|@WZj7_{a(aX+NBDhG599{g%%oB vL$1fp?FL2A)A+fYUfvTz%&Qv_PN- diff --git a/gscats.s b/gscats.s index 096e426..dec1e4c 100644 --- a/gscats.s +++ b/gscats.s @@ -37,8 +37,6 @@ mainBank2: jsr compileTerrain jsr clipTerrain -; jsr unclipTerrain -; jsr clipTerrain mainGameLoop: @@ -70,6 +68,10 @@ render: lda mapScrollRequested bpl scrollMap + lda #gameobjectData + sta PARAML0 + jsr renderGameobject + lda quitRequested beq mainGameLoop @@ -79,7 +81,12 @@ quit: scrollMap: jsr unclipTerrain + sta mapScrollPos + asl + asl + sta leftScreenEdge + jsr clipTerrain lda #$ffff sta mapScrollRequested @@ -153,8 +160,6 @@ kbdScanSpace: basePalette: .word $0000,$0080,$0000,$000F,$0FFF,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF -mapScrollPos: ; 4-pixel columns distance from right terrain edge - .word 0 quitRequested: .word $0000 mapScrollRequested: @@ -162,10 +167,18 @@ mapScrollRequested: string: pstring "HELLO WORLD" +; Position of map viewing window. Can be visualized in two ways: +; a) Word-distance from right edge of terrain data (which is in memory right-to-left) to left edge of visible screen +; b) Word-distance from left edge of logical terrain to left edge of visible screen +mapScrollPos: + .word 0 +leftScreenEdge: + .word 0 ; In pixels .include "graphics.s" .include "font.s" .include "terrain.s" +.include "gameobject.s" .include "tables.s" endMainBank2: diff --git a/player.s b/player.s deleted file mode 100644 index cf7fff3..0000000 --- a/player.s +++ /dev/null @@ -1,7 +0,0 @@ -; -; player -; Code and data structures related to the players -; -; Created by Quinn Dunki on 8/13/17 -; - diff --git a/tables.s b/tables.s index 0422ee7..ee4f3ec 100644 --- a/tables.s +++ b/tables.s @@ -43,3 +43,16 @@ vramRowEndsMinusOne: .word $781f,$78bf,$795f,$79ff,$7a9f,$7b3f,$7bdf,$7c7f,$7d1f,$7dbf,$7e5f,$7eff,$7f9f,$803f,$80df,$817f,$821f,$82bf,$835f,$83ff .word $849f,$853f,$85df,$867f,$871f,$87bf,$885f,$88ff,$899f,$8a3f,$8adf,$8b7f,$8c1f,$8cbf,$8d5f,$8dff,$8e9f,$8f3f,$8fdf,$907f .word $911f,$91bf,$925f,$92ff,$939f,$943f,$94df,$957f,$961f,$96bf,$975f,$97ff,$989f,$993f,$99df,$9a7f,$9b1f,$9bbf,$9c5f,$9cff + +vramYOffset: + .word $0000,$00a0,$0140,$01e0,$0280,$0320,$03c0,$0460,$0500,$05a0,$0640,$06e0,$0780,$0820,$08c0,$0960,$0a00,$0aa0,$0b40,$0be0 + .word $0c80,$0d20,$0dc0,$0e60,$0f00,$0fa0,$1040,$10e0,$1180,$1220,$12c0,$1360,$1400,$14a0,$1540,$15e0,$1680,$1720,$17c0,$1860 + .word $1900,$19a0,$1a40,$1ae0,$1b80,$1c20,$1cc0,$1d60,$1e00,$1ea0,$1f40,$1fe0,$2080,$2120,$21c0,$2260,$2300,$23a0,$2440,$24e0 + .word $2580,$2620,$26c0,$2760,$2800,$28a0,$2940,$29e0,$2a80,$2b20,$2bc0,$2c60,$2d00,$2da0,$2e40,$2ee0,$2f80,$3020,$30c0,$3160 + .word $3200,$32a0,$3340,$33e0,$3480,$3520,$35c0,$3660,$3700,$37a0,$3840,$38e0,$3980,$3a20,$3ac0,$3b60,$3c00,$3ca0,$3d40,$3de0 + .word $3e80,$3f20,$3fc0,$4060,$4100,$41a0,$4240,$42e0,$4380,$4420,$44c0,$4560,$4600,$46a0,$4740,$47e0,$4880,$4920,$49c0,$4a60 + .word $4b00,$4ba0,$4c40,$4ce0,$4d80,$4e20,$4ec0,$4f60,$5000,$50a0,$5140,$51e0,$5280,$5320,$53c0,$5460,$5500,$55a0,$5640,$56e0 + .word $5780,$5820,$58c0,$5960,$5a00,$5aa0,$5b40,$5be0,$5c80,$5d20,$5dc0,$5e60,$5f00,$5fa0,$6040,$60e0,$6180,$6220,$62c0,$6360 + .word $6400,$64a0,$6540,$65e0,$6680,$6720,$67c0,$6860,$6900,$69a0,$6a40,$6ae0,$6b80,$6c20,$6cc0,$6d60,$6e00,$6ea0,$6f40,$6fe0 + .word $7080,$7120,$71c0,$7260,$7300,$73a0,$7440,$74e0,$7580,$7620,$76c0,$7760,$7800,$78a0,$7940,$79e0,$7a80,$7b20,$7bc0,$7c60 +