Skip to content

Commit

Permalink
Merge pull request #21 from CJLove/samples_r37
Browse files Browse the repository at this point in the history
Update samples for r37
  • Loading branch information
yeastplume authored Jun 7, 2020
2 parents 4481f91 + 207de4c commit 314dd77
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 107 deletions.
21 changes: 8 additions & 13 deletions samples/binfiles/binfiles.bas
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
1 REM POKE MODE INTO LAYER 1
1 REM POKE MODE INTO LAYER 0
2 REM TILED, 4BPP, ON
3 REM IMAGESET ADDRESS $1A800
4 REM TILEMAP ADDRESS $10000
10 VPOKE $F,$2000,$61:VPOKE $F,$2001,$31
11 VPOKE $F,$2002,$00:VPOKE $F,$2003,$40
12 VPOKE $F,$2004,$00:VPOKE $F,$2005,$6A
4 REM TILEMAP ADDRESS $00000
5 CLS
10 POKE $9F29,$13
11 POKE $9F2D,$7: POKE $9F2E,0: POKE $9F2F,0: POKE $9F30,0
12 POKE $9F31,0: POKE $9F32, 0: POKE $9F33, 0
13 PRINT "POKING PALETTE"
14 REM POKE PALETTE DATA
20 VLOAD "KQ5PAL.BIN",8,$0F,$1000
20 VLOAD "KQ5PAL.BIN",8,$01,$FA00
30 REM POKE MODE
31 VPOKE $F,$2000,$E1:VPOKE $F,$2001,$0
32 VPOKE $F,$2002,$00:VPOKE $F,$2003,$0
33 VPOKE $F,$2004,$00:VPOKE $F,$2005,$0
34 VPOKE $F,$2006,$00:VPOKE $F,$2007,$0
35 VPOKE $F,$0001,$40:VPOKE $F,$0002,$40
31 POKE $9F2A,$40: POKE $9F2B,$40

37 VLOAD "KQ5.BIN",8,$0,$0000

40 VPOKE $F,$3000,0

1000 REM DATA WILL BE APPENDED HERE
53 changes: 20 additions & 33 deletions samples/bitmap/bitmap.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,28 @@

.code
jmp start
.proc set_mode ;target layer 1
;set layer 1 mode to tiled Bitmap Mode 8bpp
v_address_set $F2000, 1
lda #$E1 ;8bpp bitmap, on
;lda #$81 ;tiled, 8bpp, on
sta VERA_DATA0
lda #$0 ;TileW is 320
sta VERA_DATA0
;map base not used
lda #$00
sta VERA_DATA0
lda #$00
sta VERA_DATA0
;set tileset (bmp data) address to $00000
lda #$00
sta VERA_DATA0
lda #$00
sta VERA_DATA0
lda #$00
sta VERA_DATA0
lda #$00
sta VERA_DATA0 ; palette offset 0
;set hscale, vscale
v_address_set $F0001, 1
lda #$40
sta VERA_DATA0
lda #$40
sta VERA_DATA0
.proc set_mode ;target layer 0
lda #$13 ; layer 0, rgb output
sta $9F29
;set layer 0 mode to tiled Bitmap Mode 8bpp
lda #$07 ; 8bpp bitmap
sta $9F2D
lda #$0 ; map base not used
sta $9F2E
lda #$0 ; tileset address to $00000, tilewidth = 0 (320)
sta $9F2F
sta $9F30 ; hscroll=0, palette base = 0
sta $9F31
sta $9F32 ; vscroll=0
sta $9F33
lda #$40 ; hscale, vscale
sta $9F2A
sta $9F2B
rts
.endproc

.proc load_palette
v_address_set $F1000, 1
v_address_set $1FA00, 1
set_const_16 $00, palette

TARGET = 512;loop until size reached
Expand Down Expand Up @@ -69,10 +58,8 @@ start:
jsr load_bitmap
;jsr clear_map
;jsr load_tilemap
;turn off layer 2 to see our handiwork
v_address_set $F3000, 0
lda #$0 ;default, off
sta VERA_DATA0
lda #$13 ; layer 0, rgb output
sta $9F29
rts

.segment "RODATA"
Expand Down
2 changes: 1 addition & 1 deletion samples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The samples in this directory complement the examples found in the [Aloevera Usa

For the time being, sample assembly code is only provided for ca65, the assembler tool of the [cc65 project](https://github.com/cc65/). If you're interested in running the assembly samples, you'll therefore need to have the tools `ca65` and `ld65` on your system path. Both of these tools are provided as part of the `cc65` suite.

You'll also need the [x16 Emulator](https://github.com/commanderx16/x16-emulator/releases) and [ROM](https://github.com/commanderx16/x16-rom) available on your path. At the time of this writing, the target release for both is R36.
You'll also need the [x16 Emulator](https://github.com/commanderx16/x16-emulator/releases) and [ROM](https://github.com/commanderx16/x16-rom) available on your path. At the time of this writing, the target release for both is R37.

And of course, you'll need the Aloevera executable somewhere on your machine, either built locally or from a release.

Expand Down
28 changes: 16 additions & 12 deletions samples/sprites/sprites.bas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
3 REM IMAGESET ADDRESS $1A800
13 PRINT "POKING PALETTE"
14 REM POKE PALETTE DATA
20 POKE $9F20,0:POKE $9F21,$10:POKE $9F22,$1F
20 POKE $9F20,0:POKE $9F21,$FA:POKE $9F22,$11
30 FOR I = 0 TO 23
40 READ A:POKE $9F23,A:NEXT I
42 REM POKE SPRITE DATA INTO TILE BASE
Expand All @@ -11,28 +11,32 @@
70 READ A:POKE $9F23,A:NEXT I
80 REM SETUP SPRITE
81 PRINT "SETTING UP SPRITE"
90 VPOKE $F,$5000,$40:VPOKE $F,$5001,$0D
100 VPOKE $F,$5002,$30:VPOKE $F,$5003,$01
120 VPOKE $F,$5004,$0:VPOKE $F,$5005,$0
130 VPOKE $F,$5006,$0C:VPOKE $F,$5007,$90
140 VPOKE $F,$4000,$01
90 VPOKE $1,$FC00,$40: VPOKE $1,$FC01,$0D
100 VPOKE $1,$FC02,$30: VPOKE $1,$FC03,$01
120 VPOKE $1,$FC04,$0: VPOKE $1,$FC05,$0
130 VPOKE $1,$FC06,$0C: VPOKE $1,$FC07,$90
' 90 VPOKE $F,$5000,$40:VPOKE $F,$5001,$0D
' 100 VPOKE $F,$5002,$30:VPOKE $F,$5003,$01
' 120 VPOKE $F,$5004,$0:VPOKE $F,$5005,$0
' 130 VPOKE $F,$5006,$0C:VPOKE $F,$5007,$90
' 140 VPOKE $F,$4000,$01

180 REM TURN OFF LAYER 2, VIEW RESULT
190 VPOKE $F,$3000,$00
180 REM TURN OFF LAYERS 0 AND 1, VIEW RESULT
190 POKE $9F29,$43

199 REM LITTLE ANIMATION LOOP
200 LET Y=0
201 LET M=0.15
210 REM START
220 Y = Y + 2:IF Y > 255 THEN Y = 0
230 VPOKE $F,$5004,Y:VPOKE $F,$5000,$40
230 VPOKE $1,$FC04,Y:VPOKE $1,$FC00,$40
240 T=M:GOSUB 900:REM DELAY
250 VPOKE $F,$5000,$48
250 VPOKE $1,$FC00,$48
260 T=M:GOSUB 900:REM DELAY
270 Y = Y + 2:IF Y > 255 THEN Y = 0
280 VPOKE $F,$5004,Y:VPOKE $F,$5000,$50
280 VPOKE $1,$FC04,Y:VPOKE $1,$FC00,$50
290 T=M:GOSUB 900:REM DELAY
300 VPOKE $F,$5000,$48
300 VPOKE $1,$FC00,$48
310 T=M:GOSUB 900:REM DELAY
320 GOTO 210

Expand Down
20 changes: 8 additions & 12 deletions samples/sprites/sprites.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
jmp start

.proc load_palette
v_address_set $F1000, 1
v_address_set $1FA00, 1
ldx #0
loop:
lda palette,x
Expand Down Expand Up @@ -35,7 +35,7 @@ jmp start

;Set up our sprite
.proc sprite_setup
v_address_set $F5000, 1
v_address_set $1FC00, 1
lda #$40
sta VERA_DATA0
lda #$D ; Mode 0 - 4BPP
Expand All @@ -52,9 +52,6 @@ jmp start
sta VERA_DATA0
lda #$90 ; Height 32, width 16, Pal offset 0
sta VERA_DATA0
v_address_set $F4000, 1 ;Enable sprite in corresponding register
lda #$1
sta VERA_DATA0
rts
.endproc

Expand All @@ -77,20 +74,20 @@ jmp start
;little loop to run through terra's walk-cycle
.proc main_loop
loop:
v_address_set $f5004, 0 ; Move down the screen a bit
v_address_set $1fc04, 0 ; Move down the screen a bit
inc VERA_DATA0
inc VERA_DATA0
v_address_set $f5000, 0
v_address_set $1fc00, 0
lda #$40
sta VERA_DATA0
jsr delay
lda #$48
sta VERA_DATA0
jsr delay
v_address_set $f5004, 0 ; Move down the screen a bit
v_address_set $1fc04, 0 ; Move down the screen a bit
inc VERA_DATA0
inc VERA_DATA0
v_address_set $f5000, 0
v_address_set $1fc00, 0
lda #$50
sta VERA_DATA0
jsr delay
Expand All @@ -105,10 +102,9 @@ start:
jsr load_sprite
jsr sprite_setup
jsr delay
;turn off layer 2 for effect
lda #$43 ; sprites, rgb output
sta $9F29
v_address_set $F3000, 0
lda #$0 ;default, off
sta VERA_DATA0
jsr main_loop
rts

Expand Down
27 changes: 17 additions & 10 deletions samples/tile_wall/tile_wall.bas
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
1 REM POKE MODE INTO LAYER 1
1 REM POKE MODE INTO LAYER 0
2 REM TILED, 4BPP, ON
3 REM IMAGESET ADDRESS $1A800
4 REM TILEMAP ADDRESS $10000
10 VPOKE $F,$2000,$61:VPOKE $F,$2001,$31
11 VPOKE $F,$2002,$00:VPOKE $F,$2003,$40
12 VPOKE $F,$2004,$00:VPOKE $F,$2005,$6A
13 PRINT "POKING PALETTE"
4 REM TILEMAP ADDRESS $00000
10 POKE $9F2D,$12: POKE $9F2E,$00: POKE $9F2F,$D7
11 POKE $9F30,$0: POKE $9F31,$0: POKE $9F32,$0: POKE $9F33,$0
12 POKE $9F29,$33
13 CLS: PRINT "POKING PALETTE"
14 REM POKE PALETTE DATA
20 POKE $9F20,0:POKE $9F21,$10:POKE $9F22,$1F
20 POKE $9F20,0:POKE $9F21,$FA:POKE $9F22,$11
30 FOR I = 0 TO 29
40 READ A:POKE $9F23,A:NEXT I
42 REM POKE IMAGESET DATA INTO TILE BASE
Expand All @@ -18,19 +18,26 @@

71 REM POKE TILEMAP DATA INTO MAP BASE
72 REM START AT BASE + $500 AS PER PANE DATA
73 FOR X = 0 TO 63
74 FOR Y = 0 TO 31
75 LET S = Y * 128 + X * 2
76 VPOKE 0,S,0
77 VPOKE 0,S+1,0
78 NEXT Y
79 NEXT X
80 LET C = 0
90 LET K = 0
96 PRINT "POKING TILEMAP"
100 REM START
110 LET S = 1280 + C + K:REM $500
120 LET R% = S/256
130 POKE $9F20,S AND $FF:POKE $9F21,R%
135 POKE $9F22, $11: REM SET HIGH ADDR TO
135 POKE $9F22, $10: REM SET HIGH ADDR TO
140 FOR I = 0 TO 45
150 READ A:POKE $9F23,A: C=C+1: NEXT I
160 K = K + 82
170 IF C < 414 GOTO 100
180 REM TURN OFF LAYER 2, VIEW RESULT
190 VPOKE $F,$3000,$00
180 REM TURN OFF LAYER 1, VIEW RESULT
190 POKE $9F29,$13

1000 REM DATA WILL BE APPENDED HERE
47 changes: 21 additions & 26 deletions samples/tile_wall/tile_wall.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@

.code
jmp start
.proc set_mode ;target layer 1
;set layer 1 mode to tiled 4bpp, 64x32
v_address_set $F2000, 1
lda #$61 ;tiled, 4bpp, on
;lda #$81 ;tiled, 8bpp, on
sta VERA_DATA0
lda #$31 ;16x16 tile, 64x32 map width/height
sta VERA_DATA0
;set tilemap address to $10000
lda #$00
sta VERA_DATA0
lda #$40
sta VERA_DATA0
;set tileset (imageset) address to $1A800
lda #$00
sta VERA_DATA0
lda #$6A
sta VERA_DATA0
.proc set_mode ;target layer 0
lda #$12 ; 4bpp, 64x32 map
sta $9F2D
lda #$00 ; map base $00000
sta $9F2E
lda #$d7 ; tile base $1A800, 16x16 tiles
sta $9F2F
lda #$0 ; zero out hscroll and vscroll hi and low
sta $9F30
sta $9F31
sta $9F32
sta $9F33
lda #$33 ; enable layer 0 and 1, rgb
sta $9F29
rts
.endproc

.proc load_palette
v_address_set $F1000, 1
v_address_set $1FA00, 1
ldx #0
loop:
lda palette,x
Expand Down Expand Up @@ -57,7 +53,7 @@ jmp start
.proc clear_map
VAR_ENTRIES_WRITTEN = $00
set_const_16 VAR_ENTRIES_WRITTEN, 0
v_address_set $10000, 1
v_address_set $00000, 1
loop:
;index at 0 is an empty tile in our map
lda #0
Expand Down Expand Up @@ -89,7 +85,7 @@ jmp start
sta VERA_ADDR_LO
lda $01
sta VERA_ADDR_MID
lda #$11
lda #$10
sta VERA_ADDR_HI
set_const_16 VAR_BYTES_WRITTEN_CUR_ROW, 0
loop:
Expand All @@ -105,7 +101,7 @@ jmp start
.endproc

.proc load_tilemap_conflated
v_address_set $10000, 1
v_address_set $00000, 1
set_const_16 $00, tilemap_conflated

TARGET = 4096 ;loop until size reached
Expand All @@ -126,10 +122,9 @@ start:
jsr load_tilemap
;Alternatively, comment in below for the conflated straight-load version
;jsr load_tilemap_conflated
;turn off layer 2 to see our handiwork
v_address_set $F3000, 0
lda #$0 ;default, off
sta VERA_DATA0
;turn off layer 1 to see our handiwork
lda #$13 ; layer 0 only, rgb
sta $9F29
rts

.segment "RODATA"
Expand Down

0 comments on commit 314dd77

Please sign in to comment.