Skip to content

Commit 5ff11b8

Browse files
committed
Updated for VERA 0.9
1 parent 159d683 commit 5ff11b8

File tree

11 files changed

+171
-227
lines changed

11 files changed

+171
-227
lines changed

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,9 @@ to have a palette offset to choose which "row" of 16 colors from
5555
the 256-color palette will be used.
5656

5757
The elements of the game consist of three independent layers:
58-
* 320x200 Bitmap backgound, placed 8 pixels from the top of the screen, then end 32 pixels from the bottom. The entire bitmap
59-
will comprise of only 16 colors, taken from a palette offset.
60-
* 40x30 map of 8x8 tiles. Each tile can have 16 colors, but also
61-
its own palette offset. The tiles provide a menu at the top of the
62-
screen, text display and controls at the bottom. Tiles may also
63-
act as static overlays on top of the background. Up to 720 unique
64-
tiles can be defined.
65-
* 128 individual 16x16 sprites, including a dynamic mouse cursor.
66-
Each sprite can have 16 colors, from its own palette offset. Up to 512 unique sprite frames can be defined. All sprites except for the mouse cursor are confined to the bitmap area, and support collision
67-
with other sprites and tiles. The mouse cursor is context-sensitive,
68-
changing its frame based on its position and game state to indicate
69-
the type of action that will happen when the mouse button is clicked.
58+
* 320x200 Bitmap backgound, placed 8 pixels from the top of the screen, then end 32 pixels from the bottom. The entire bitmap will comprise of only 16 colors, taken from a palette offset.
59+
* 40x30 map of 8x8 tiles. Each tile can have 16 colors, but also its own palette offset. The tiles provide a menu at the top of the screen, text display and controls at the bottom. Tiles may also act as static overlays on top of the background. Up to 704 unique tiles can be defined.
60+
* 128 individual 16x16 sprites, including a dynamic mouse cursor. Each sprite can have 16 colors, from its own palette offset. Up to 499 unique sprite frames can be defined. All sprites except for the mouse cursor are confined to the bitmap area, and support collision with other sprites and tiles. The mouse cursor is context-sensitive, changing its frame based on its position and game state to indicate the type of action that will happen when the mouse button is clicked.
7061

7162
## Memory Map
7263
Main RAM ($0801-$9EFF): XCI engine code, top-level game data (starting at $6000)
@@ -90,8 +81,9 @@ zone is loaded to banked RAM from the file system. Up to 256
9081
different zones can be defined.
9182

9283
VRAM:
93-
* Bank 0: Bitmap ($0000-$95FF), Tile Map ($9600-$A5FF), Tiles ($A600-$FFFF)
94-
* Bank 1: Sprites ($0000-$FFFF)
84+
* Bank 0: Bitmap ($0000-$95FF), Tile Map ($9600-$A5FF),
85+
Unused ($A600-$A7FF), Tiles ($A800-$FFFF)
86+
* Bank 1: Sprites ($0000-$F9BF), VERA registers ($F9C0-$FFFF)
9587

9688
## Data Format
9789
All game data (except for background bitmaps and music files) are described in text files, starting with a main file. This file defines the top-level game data, providing references to all other source files. Its filename is the only command-line input to the software development kit (SDK) executable (**xci.exe**). It is simply a set of key-value pairs. There are certain mandatory keys that are required for the game to be successfully built. Unrecognized keys are ignored by the build utility, as are comments, which begin with a hash (```#```) symbol. Keys have no spaces and are not case-sensitive, but values may be case-sensitive and consist of all text after the first whitespace after the key up to the end of the line or the start of a comment. A value can contain a hash character by escaping it with a backslash (i.e. ```\#```). And if a value contains a backslash character, that can be escaped with a double backslash (```\\```).
@@ -128,7 +120,7 @@ $ /path/to/xci.exe mygame.xci
128120
If it finishes without errors, the game is built! Let's assume that zone 0 has 2 levels, zone 1 has 3 levels, and zone 2 a full 10 levels. The following binaries will be generated:
129121

130122
* **MAIN.BIN** - This is the compiled version of **mygame.xci**. This will be loaded into base RAM by the XCI program (**XCI.PRG**) at run time. This and all binaries generated by the build utility (in addition to **XCI.PRG**) need to be loaded into the X16 file system to run the game. It will contain information from **mygame.xci** and other files specified by the main file keys.
131-
* **PAL.BIN** - This is the initial palette for the game, as specified by the filename after the **palette** key (**mygame_pal.hex**) and other configuration data. It will be loaded by the XCI program into VRAM (F:1000) prior to displaying the title screen. Note that the palette beyond index 15 will be modified as different parts of the game are loaded.
123+
* **PAL.BIN** - This is the initial palette for the game, as specified by the filename after the **palette** key (**mygame_pal.hex**) and other configuration data. It will be loaded by the XCI program into VRAM (1:FA00) prior to displaying the title screen. Note that the palette beyond index 15 will be modified as different parts of the game are loaded.
132124
* **TILES.BIN** - This is the binary version of **mygame_tiles.hex**, which contains the tile set for the game, as specified by the **tiles_hex** key. It will be loaded by the XCI program into VRAM (0:A600) prior to displaying the title screen.
133125
* **SPRITES.BIN** - This is the binary version of **mygame_sprites.hex**, which contains the sprite frames for the game, as specified by the **sprites_hex** key. It will be loaded by the XCI program into VRAM (1:0000) prior to displaying the title screen.
134126
* **TTL.BM.BIN** - This is the background bitmap for the title screen, specified by the contents of **mygame_start.xci**, which will be explained later. It will be loaded into VRAM (0:0000) once the palette, tiles and sprites are all loaded. Unlike the background bitmaps of the game levels, this bitmap can take up the full screen (320x240). This will remain in VRAM and on screen until the player starts a new game or loads a saved game. It is never stored in base or banked RAM.

engine/globals.asm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ XGF_PTR = $3A
102102

103103
VRAM_BITMAP = $00000 ; 4bpp 320x240
104104
VRAM_TILEMAP = $09600 ; 64x32 (40x30 visible)
105-
VRAM_TILES = $0A600 ; 720 4bpp 8x8 tiles
106-
VRAM_SPRITES = $10000 ; 512 4bpp 16x16 frames
105+
VRAM_TILES = $0A800 ; 704 4bpp 8x8 tiles
106+
VRAM_SPRITES = $10000 ; 499 4bpp 16x16 frames
107107

108108
LEVEL_BITMAP_OFFSET = 8*320/2
109109
VRAM_LEVEL_BITMAP = VRAM_BITMAP + LEVEL_BITMAP_OFFSET
110110
LEVEL_BITMAP_SIZE = 200*320/2
111111
VRAM_TEXTFIELD_BITMAP_BG = VRAM_LEVEL_BITMAP + LEVEL_BITMAP_SIZE
112112
TEXTFIELD_BITMAP_BG_SIZE = 32*320/2
113113

114+
BITMAP_PO = VERA_L0_hscroll_h
115+
114116
TILEMAP_SIZE = VRAM_TILES - VRAM_TILEMAP
115117

116118
.ifndef TTL_MUS_BANK

engine/help.asm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ __help_show:
1212
lda #1
1313
sta help_visible
1414
stz VERA_ctrl
15-
VERA_SET_ADDR VRAM_sprreg, 0 ; disable sprites
16-
stz VERA_data0
15+
; disable sprites
16+
lda VERA_dc_video
17+
and #$BF
18+
sta VERA_dc_video
1719
lda __help_start_ptr
1820
tay
1921
stz HELP_PTR
@@ -75,10 +77,12 @@ help_tick:
7577
lda mouse_left_click
7678
beq @return
7779
stz help_visible
80+
ldy #1
7881
jsr tile_restore
79-
VERA_SET_ADDR VRAM_sprreg, 0 ; enable sprites
80-
lda #$01
81-
sta VERA_data0
82+
; enable sprites
83+
lda VERA_dc_video
84+
ora #$40
85+
sta VERA_dc_video
8286
@return:
8387
rts
8488

engine/irq.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ init_irq:
2020

2121
handle_irq:
2222
; check for VSYNC
23-
lda VERA_irq
23+
lda VERA_isr
2424
and #$01
2525
beq @done_vsync
2626
sta vsync_trig
2727
; clear vera irq flag
28-
sta VERA_irq
28+
sta VERA_isr
2929

3030
@done_vsync:
3131

engine/level.asm

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,11 @@ __level_quant: .word 0
3333

3434
load_level:
3535
; blackout bitmap
36-
stz VERA_ctrl
37-
lda #LAYER_BM_OFFSET
38-
sta VERA_addr_low
39-
lda #>VRAM_layer0
40-
sta VERA_addr_high
41-
lda #(^VRAM_layer0 | $10)
42-
sta VERA_addr_bank
4336
lda #BLACK_PO
44-
sta VERA_data0
37+
sta BITMAP_PO
4538

4639
; clear level tiles
40+
ldy #1
4741
jsr tile_clear
4842

4943
; reset UI state
@@ -54,7 +48,7 @@ load_level:
5448
sta current_item
5549

5650
; disable all sprites except mouse cursor
57-
VERA_SET_ADDR $F500E, 4 ; sprite 1 byte 6, stride of 8
51+
VERA_SET_ADDR $1FC0E, 4 ; sprite 1 byte 6, stride of 8
5852
ldx #1
5953
@clear_sprite_loop:
6054
stz VERA_data0
@@ -225,16 +219,10 @@ load_level:
225219
ldx #0
226220
ldy #0
227221
jsr bank2vram
228-
lda #LAYER_BM_OFFSET ; set palette offset
229-
sta VERA_addr_low
230-
lda #>VRAM_layer0
231-
sta VERA_addr_high
232-
lda #(^VRAM_layer0 | $10)
233-
sta VERA_addr_bank
234222
lda level
235223
clc
236224
adc #LEVEL0_PO
237-
sta VERA_data0
225+
sta BITMAP_PO
238226

239227
jsr level_continue
240228
ldx level

engine/menu.asm

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,8 @@ init_menu:
159159
@tilemap: .word 0
160160
@start:
161161
; blackout bitmap
162-
stz VERA_ctrl
163-
lda #LAYER_BM_OFFSET
164-
sta VERA_addr_low
165-
lda #>VRAM_layer0
166-
sta VERA_addr_high
167-
lda #(^VRAM_layer0 | $10)
168-
sta VERA_addr_bank
169162
lda #BLACK_PO
170-
sta VERA_data0
163+
sta BITMAP_PO
171164

172165
; clear all tiles
173166
VERA_SET_ADDR VRAM_TILEMAP, 1
@@ -189,7 +182,7 @@ init_menu:
189182
bne @clear_tile_loop
190183

191184
; disable all sprites except mouse cursor
192-
VERA_SET_ADDR $F500E, 4 ; sprite 1 byte 6, stride of 8
185+
VERA_SET_ADDR $1FC0E, 4 ; sprite 1 byte 6, stride of 8
193186
ldx #1
194187
@clear_sprite_loop:
195188
stz VERA_data0
@@ -427,6 +420,7 @@ menu_tick:
427420
cmp #SAVE_GAME_AS
428421
beq @auto_hide
429422
@restore:
423+
ldy #1
430424
jsr tile_restore
431425
@auto_hide:
432426
stz __menu_visible

0 commit comments

Comments
 (0)