Skip to content

Commit

Permalink
Use PETSCII editor for building levels
Browse files Browse the repository at this point in the history
  • Loading branch information
turesheim committed Dec 7, 2023
1 parent 6f979bf commit 4b62a11
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 114 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
/itema.vs
/bin/
source.txt
.source.txt
itema.asm
petscii/convert-screens.prg
petscii/convert-screens.mod
petscii/convert-screens.sym
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ This game requires a paddle to play. When using the VICE emulator, add the follo

* [Codebase64](https://codebase64.org/doku.php?id=start)
* [Dustlayer](https://dustlayer.com)
* [Kick Assembler User Guide](http://www.theweb.dk/KickAssembler/webhelp/content/cpt_Introduction.html)
58 changes: 1 addition & 57 deletions screens.asm → font.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*=$3800
*=$3800 "Custom character set"
.byte $18, $18, $18, $FF, $FF, $18, $18, $18
.byte $3C, $24, $24, $7E, $62, $62, $62, $62
.byte $7C, $44, $44, $7E, $62, $62, $62, $7E
Expand Down Expand Up @@ -256,59 +256,3 @@
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00

*=$2800
background:
.byte $28, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $26, $21, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $09, $14, $05, $0D, $01, $20, $20, $20, $20, $20
.byte $24, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $25, $29, $20, $08, $01, $03, $0B, $01, $14, $08, $0F, $0E, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $06, $12, $1B, $19, $01, $20, $32, $30, $32, $33, $20, $20
.byte $24, $20, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $20, $20, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $7F, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $20, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $7F, $7F, $7F, $E0, $E0, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $E1, $E1, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $7F, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $7F, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $7F, $7F, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $7F, $7F, $2B, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $7F, $7F, $7F, $7F, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $7F, $7F, $7F, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $7F, $80, $81, $7F, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $7F, $7F, $7F, $80, $81, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $80, $81, $E3, $E3, $80, $81, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $80, $81, $E3, $E3, $80, $81, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $80, $81, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $80, $81, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $7F, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $40, $41, $42, $43, $44, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $50, $51, $52, $53, $54, $20, $20, $20
.byte $24, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $25, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $22, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $27, $23, $29, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20
.byte $ff

colormap:
.byte $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $05, $05, $03, $03, $03, $03, $03, $03, $03, $03, $03, $07
.byte $07, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $07, $00, $07, $03, $03, $03, $03, $03, $03, $03, $03, $03, $05, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $07, $07
.byte $07, $0F, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $0F, $0F, $08, $08, $08, $08, $08, $08, $08, $08, $08, $08, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $0F, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $03, $03, $03, $07, $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $07, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $03, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $08, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $08, $08, $03, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $08, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $03, $03, $03, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $03, $03, $03, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $03, $03, $07, $07, $03, $03, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $07, $07, $03, $03, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $03, $03, $0D, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $03, $03, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0D, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $0F, $0F, $0F, $0F, $0F, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $0F, $0F, $0F, $0F, $0F, $07, $07, $07
.byte $07, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $00, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07, $07
.byte $ff
68 changes: 36 additions & 32 deletions itema.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
#import "libSprite.asm"
#import "libInput.asm"
#import "libScreen.asm"
#import "screens.asm"
#import "font.asm"

BasicUpstart2(initialize)


.var music = LoadSid("music/Nightshift.sid") //<- Here we load the sid file
.var demo_mode_movement_timer = $0

Expand Down Expand Up @@ -48,16 +49,17 @@ initialize:

lda #$00 // Set sprite/background priority
sta $d01b



lda #$00 // Disable xpand-x
sta $d01d

lda #$0a // Set sprite #1 individual color
sta $d027
lda #$0c // Set sprite #2 individual color
sta $d028

lda #paddleSpriteData/64
sta $07f8 // Sprite #0
lda #ballSpriteData/64
Expand Down Expand Up @@ -100,7 +102,7 @@ initialize:


/*
Set character set pointer to our custom set, turn off
Set character set pointer to our custom set, turn off
multicolor for characters
*/

Expand All @@ -113,16 +115,24 @@ and #%11101111 // by clearing bit #4 of $D016
sta $d016

/*
Print the first level from the second line from the top
Initialize IRQ
*/
MEMCOPY(background, $0400)
MEMCOPY(colormap, $d800)
jsr init_irq

/*
Initialize IRQ
Load the initial screen
$4500 - intro screen
$4d00 - level 1
*/
jsr init_irq
lda #$4d
sta $ff
lda #$00
sta $fe
jsr load_screen

/*
Main loop
*/
loop:
jmp loop

Expand All @@ -137,7 +147,7 @@ demo_input:
isSmaller:
sta temp
lda SpriteMem+9
sbc #$06 // Adjust for ball radius
sbc #$06 // Adjust for ball radius
adc temp
jsr store_xl // Store the paddle x-position
rts
Expand Down Expand Up @@ -171,27 +181,20 @@ paddle_input:
rts

init_irq:

lda #$00
ldx #0
ldy #0
lda #music.startSong-1
jsr music.init

sei
lda #<irq_1
ldx #>irq_1
sta $0314
stx $0315 // Set interrupt addr
stx $0315 // Set interrupt addr
lda #$7f
sta $dc0d // Timer A off on cia1/kb
sta $dd0d // Timer A off on cia2

lda #$81
sta $d01a // Raster interrupts on
/*
lda #$1b // Screen ctrl: default
sta $d011

*/
lda #$01
sta $d012 // Interrupt at line 0

Expand All @@ -205,7 +208,7 @@ irq_1:
lda #$00
sta SpriteIndex
jsr paddle_input

animation_loop:

clc
Expand All @@ -223,7 +226,7 @@ irq_1:
move_ball_normally:
jsr move_vertically

move_paddle:
move_paddle:
jsr move_horizontally
jsr draw_sprite
jsr check_collision
Expand All @@ -235,12 +238,7 @@ irq_1:
beq done
jmp animation_loop
done:
asl $d019
// No music in the main loop
/// inc $d020
// jsr music.play
// dec $d020
// dec $d020
asl $d019 // Clear interrupt flag
jmp $ea81 // set flag and end

/*
Expand All @@ -264,8 +262,14 @@ accelerated_movement:
jsr store_ya
jmp move_ball_normally

*=music.location "Music"
.fill music.size, music.getData(i) // <- Here we put the music in memory
// Intro screen
.var intro_background = LoadBinary("petscii/intro.bin")
*=$4500 "Intro"
.fill intro_background.getSize(), intro_background.get(i)
// Level 1
.var lvl1_background = LoadBinary("petscii/level_1.bin")
*=$4d00 "Level 1"
.fill lvl1_background.getSize(), lvl1_background.get(i)

// -- Sprite Data --------------------------------------------------------------
// Created using https://www.spritemate.com
Expand Down
82 changes: 80 additions & 2 deletions libScreen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ loop:
inx
jmp loop
out:
rts:
rts:
}

.const MEMCP_SRCVECT = $fb
.const MEMCP_SRCVECT = $f9
.const MEMCP_DSTVECT = MEMCP_SRCVECT + 2
.const MEMCP_CNTVECT = MEMCP_DSTVECT + 2
.macro MEMCOPY(src, dst)
{
// NB! The vector for index indirect addressing is little-endian
Expand Down Expand Up @@ -47,3 +48,80 @@ memcp_nextpage:
jmp memcp_loop
memcp_out:
}

/*
Load a screen from the address prepared in in zeropage
$fe – lowest byte
$ff - highest byte
*/
load_screen:

// Start with the characters
lda #$00
sta MEMCP_DSTVECT
lda $fe // zeropage
sta MEMCP_SRCVECT
lda #$04
sta MEMCP_DSTVECT+1
lda $ff // zeropage
sta MEMCP_SRCVECT+1
lda #$00
sta MEMCP_CNTVECT // Initialize low byte of counter
sta MEMCP_CNTVECT+1 // Initialize high byte of counter

jsr copy_loop

// Now do the colours
lda $fe // Load the low byte of the pointer
clc // Clear carry flag before addition
adc #$e5 // Add the LSB for modification
sta MEMCP_SRCVECT

lda $ff // Load the high byte of the pointer
adc #$03 // Add the MSB for modification
bcc noCarry // Branch if no carry from the first addition
adc #$01 // Add the carry from the first addition
noCarry:
sta MEMCP_SRCVECT+1

// Set the destination to colour memory at $d800
lda #$00
sta MEMCP_DSTVECT
lda #$d8
sta MEMCP_DSTVECT+1
lda #$00
sta MEMCP_CNTVECT // Initialize low byte of counter
sta MEMCP_CNTVECT+1 // Initialize high byte of counter

copy_loop:
ldy MEMCP_CNTVECT // Load low byte of counter into Y

lda (MEMCP_SRCVECT),Y // Load byte from source address + Y into A
sta (MEMCP_DSTVECT),Y // Store byte from A at target address + Y

inc MEMCP_CNTVECT // Increment low byte of counter
bne check_counter
inc MEMCP_CNTVECT+1 // If low byte overflowed, increment high byte

check_counter:
lda MEMCP_CNTVECT
cmp #$e8 // Check if low byte of counter has reached 0xe8
bne continue_loop

lda MEMCP_CNTVECT+1
cmp #$03 // Check if high byte of counter has reached 0x03
bne continue_loop

jmp end_loop // If we've copied 1000 bytes, end the loop

continue_loop:
iny // Increment Y
bne copy_loop
inc MEMCP_SRCVECT+1 // If Y overflowed, increment high byte of source address
inc MEMCP_DSTVECT+1 // If Y overflowed, increment high byte of target address
jmp copy_loop // Jump back to the start of the loop

end_loop:

rts
Loading

0 comments on commit 4b62a11

Please sign in to comment.