Skip to content

Commit

Permalink
Clean up a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
turesheim committed Jan 17, 2024
1 parent bb294f6 commit b318524
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 46 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/itema.prg
/itema.sym
/itema.vs
/*.prg
/*.sym
/*.vs
/bin/
source.txt
.source.txt
itema.asm
petscii/convert-screens.prg
petscii/convert-screens.mod
petscii/convert-screens.sym
out
/_library/
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>net.resheim.eclipse.kickassembler.core.kickassemblerBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>net.resheim.eclipse.kickassembler.core.kickassemblerNature</nature>
</natures>
</projectDescription>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,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)
* [KickAssembler syntax for Vim](https://github.com/gryf/kickass-syntax-vim)
49 changes: 17 additions & 32 deletions itema.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Bouncing ball demo
A small Breakout-like game featuring balls with simulated physics

Copyright (c) 2020-2023 Itema AS

Expand All @@ -13,20 +13,18 @@

* = $c000 "Main Program"

// import our sprite library
#import "libSprite.asm"
#import "libInput.asm"
#import "libScreen.asm"
#import "font.asm"

BasicUpstart2(initialize)


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

// Initialize
initialize:
initialize:
jsr $e544 // Clear screen

lda #$06 // Set the background color for the game area
Expand Down Expand Up @@ -108,8 +106,8 @@ initialize:

lda $d018
ora #%00001110 // Set chars location to $3800 for displaying the custom font
sta $d018 // Bits 1-3 ($0400 + 512 .bytes * low nibble value) of $D018 sets char location
// $400 + $200*$0E = $3800
sta $d018 // Bits 1-3 ($0400 + 512 .bytes * low nibble value) of $D018
//sets char location $400 + $200*$0E = $3800
lda $d016 // turn off multicolor for characters
and #%11101111 // by clearing bit #4 of $D016
sta $d016
Expand All @@ -119,39 +117,26 @@ sta $d016
*/
jsr init_irq

/*
Load the initial screen
$4500 - intro screen
$4d00 - level 1
*/
lda #$4d
sta $ff
lda #$00
sta $fe
jsr load_screen
LOAD_SCREEN(1)

/*
Main loop
*/
loop:
jmp loop

/*
Use this for demo input, it's very stupid and needs improvement
*/
demo_input:
lda $d012
eor $dc04
sbc $dc05 // Get a pseudo random number from CIA timers
and #$0F
cmp #$08
bcc isSmaller
sbc #$08
isSmaller:
sta temp
lda SpriteMem+9
sbc #$06 // Adjust for ball radius
adc temp
jsr store_xl // Store the paddle x-position
lda SpriteMem+9 // Get the x-position of the ball
sbc #$03 // Adjust for ball radius
jsr paddle_position
rts

/*
Use this for actual player input
*/
paddle_input:
lda $dc00 // Load value from CIA#1 Data Port A (pot lines are input)
and #%11111110 // Set bit 0 to input for pot x (paddle 1)
Expand All @@ -164,8 +149,8 @@ paddle_input:
lda $d419 // Load value from Paddle X pot
eor #$ff // XOR with 255 to reverse the range

// Update paddle position unless it is outside the playing area

// Update paddle position unless it is outside the playing area
paddle_position:
clc
cmp #$1a // Compare with the minimum value
bcs piNotLess // If carry is set (number >= minValue), branch to piNotLess
Expand Down Expand Up @@ -208,9 +193,9 @@ irq_1:
lda #$00
sta SpriteIndex
jsr paddle_input
//jsr demo_input

animation_loop:

clc
lda SpriteIndex
cmp #$00
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion libInput.asm → library/libInput.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
{
lda $DC00 // Load joystick 2 state to A
and #portMask // Mask out direction/fire required
} // Test with bne immediately after the call
} // Test with bne immediately after the call
29 changes: 24 additions & 5 deletions libScreen.asm → library/libScreen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,40 @@ memcp_nextpage:
memcp_out:
}

/*
For each screen added, specify the pointer to it using the little
endian adress.
*/
ScreenPointers:
.byte $00, $45 // Introduction screen
.byte $00, $4d // Level 1

/*
Use this to load a screen number.
*/
.macro LOAD_SCREEN(number){
ldx number
lda ScreenPointers+(number*2)
sta $fe
lda ScreenPointers+(number*2)+1
sta $ff
jsr load_screen
}

/*
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
lda $fe
sta MEMCP_SRCVECT
lda #$04
sta MEMCP_DSTVECT+1
lda $ff // zeropage
lda $ff
sta MEMCP_SRCVECT+1
lda #$00
sta MEMCP_CNTVECT // Initialize low byte of counter
Expand All @@ -81,7 +100,7 @@ load_screen:
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

Expand Down Expand Up @@ -124,4 +143,4 @@ continue_loop:

end_loop:

rts
rts
2 changes: 1 addition & 1 deletion libSprite.asm → library/libSprite.asm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ get_sprite_offset:
cpx #$00
beq got_sprite_offset
clc
adc #$2
adc #$02
dex
jmp get_sprite_offset_loop

Expand Down
2 changes: 1 addition & 1 deletion libSpriteData.asm → library/libSpriteData.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SpriteMem:
xl xm yl ym xv yv xa ya f
*/
.byte $73, $00, $e0, $00, $00, $00, $00, $00, $00 // Paddle (the player)
.byte $73, $00, $60, $00, $00, $00, $00, $00, $00 // Ball 1
.byte $33, $00, $60, $00, $30, $00, $00, $00, $00 // Ball 1
.byte $73, $00, $70, $00, $00, $00, $00, $00, $00 // Ball 2
.byte $18, $00, $62, $00, $00, $00, $00, $00, $00
.byte $18, $00, $72, $00, $00, $00, $00, $00, $00
Expand Down
7 changes: 6 additions & 1 deletion petscii/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Generating level files


**Prerequisites:**

- Kick Assembler
- `x64sc` in `$PATH`

Use http://petscii.krissz.hu/ to design the levels:

1. Load `itemaball.pe` found in this folder
Expand All @@ -9,4 +15,3 @@ Use http://petscii.krissz.hu/ to design the levels:
- level screens must be named 'level_<n>.seq'
4. Update 'convert-screens.sh'
5. Run 'convert-screens.sh'

2 changes: 1 addition & 1 deletion petscii/convert-screens.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
This program will read PETSCII commands crom the SEQ file generated by the
This program will read PETSCII commands from the SEQ file generated by the
online PETSCII editor at http://petscii.krissz.hu. These files are
basically a sequence of bytes, where each byte is a PETSCII character.

Expand Down
Binary file modified petscii/intro.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion petscii/intro.seq
Original file line number Diff line number Diff line change
@@ -1 +1 @@
����(&&&&&&&&&&&&&&&&&&&&&&&&!�) �$� �%�)�  �ITEMA � $� � � �%�)� $ � �%�)� �HACKATHON � $ � �%�)� $ � �%�)� �FR[YA 2023� $ INSERT PADDLE INTO����� �%�)� $� � � �%�)� $� � PORT 1 AND PRESS � �%�)� $� � � �%�)� $� ���� FIRE TO PLAY � �%�)� $� � ��� �%�)� $� � � ���� �%�)� $� ����� � ����+�%�)� $� ������ ��� ������ �%�)� $� � � ��� � �%�)� $ � �%�)� $� � � � � �%�)� $� ��� �%�)� $� �%�)� $� �COPYRIGHT 2023� �%�)� $� �%�)� �`abcd� $� � ITEMA AS � �%�)� �pqrst� $ � �%�)� ""''''''''''''''''''''''''#�)� �
����(&&&&&&&&&&&&&&&&&&&&&&&&!�) �$� �%�)�  �ITEMA � $� � � �%�)� $ � �%�)� �HACKATHON � $ � �%�)� $ � �%�)� �FR[YA 2023� $ INSERT PADDLE INTO� � �%�)� $� � � �%�)� $� � PORT 1 AND PRESS � �%�)� $� � � �%�)� $����� � FIRE TO PLAY � ������%�)� $� � � � �%�)� $� � � � � � �%�)� $� � � �%�)� $� � ����������� � � � � �%�)� $� � � � � � � �%�)� $� � �%�)� $� � � � � � � ����� � � � �%�)� $� � � ����� �%�)� $� �%�)� $� � COPYRIGHT 2023� �%�)� $� �%�)� �`abcd� $� � ITEMA AS � �%�)� �pqrst� $ � �%�)� ""''''''''''''''''''''''''#�)� �

0 comments on commit b318524

Please sign in to comment.