1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-21 10:31:25 +00:00

Add architecture-dependent "joy2delta.60p" to "standard library".

This commit is contained in:
Chris Pressey 2019-10-22 16:09:58 +01:00
parent dc4677ade8
commit 1b5f4c0c4b
5 changed files with 43 additions and 77 deletions

View File

@ -24,6 +24,8 @@ History of SixtyPical
generation for constructs in tail position, notably
tail optimization of `calls`, but also for `goto`s and
`if` blocks at the end of a routine.
* Began collecting architecture-specific and portable
include-files for a nascent "standard library".
0.20
----

View File

@ -78,16 +78,11 @@ zero-page locations to be re-used.
Implementation
--------------
### Line numbers in analysis error messages
### Filename and line number in analysis error messages
For analysis errors, there is a line number, but it's the line of the routine
after the routine in which the analysis error occurred. Fix this.
### Libraries
Now that we have dead-code removal, establish some libraries of reusable
routines.
Blue-skying
-----------

View File

@ -2,6 +2,8 @@
// * Demo Game for SixtyPical *
// ****************************
include "joy2delta.60p"
// ----------------------------------------------------------------
// Type Definitions
// ----------------------------------------------------------------
@ -56,7 +58,6 @@ byte vic_border @ 53280
byte vic_bg @ 53281
byte table[2048] screen @ 1024
byte table[2048] colormap @ 55296
byte joy2 @ $dc00
// ----------------------------------------------------------------
// Global Variables
@ -69,7 +70,6 @@ word pos
word new_pos
word table[256] actor_delta
word delta
byte player_died
@ -103,39 +103,6 @@ vector game_state_routine
// Utility Routines
// ----------------------------------------------------------------
define read_stick routine
inputs joy2
outputs delta
trashes a, x, z, n
{
ld x, joy2
ld a, x
and a, 1 // up
if z {
copy $ffd8, delta // -40
} else {
ld a, x
and a, 2 // down
if z {
copy word 40, delta
} else {
ld a, x
and a, 4 // left
if z {
copy $ffff, delta // -1
} else {
ld a, x
and a, 8 // right
if z {
copy word 1, delta
} else {
copy word 0, delta
}
}
}
}
}
// You can repeatedly (i.e. as part of actor logic or an IRQ handler)
// call this routine.
// Upon return, if carry is set, the button was pressed then released.

View File

@ -1,40 +1,6 @@
include "joy2delta.60p"
word screen @ 1024
byte joy2 @ $dc00
word delta
define read_stick routine
inputs joy2
outputs delta
trashes a, x, z, n
{
ld x, joy2
ld a, x
and a, 1 // up
if z {
copy $ffd8, delta // -40
} else {
ld a, x
and a, 2 // down
if z {
copy word 40, delta
} else {
ld a, x
and a, 4 // left
if z {
copy $ffff, delta // -1
} else {
ld a, x
and a, 8 // right
if z {
copy word 1, delta
} else {
copy word 0, delta
}
}
}
}
}
define main routine
inputs joy2

36
include/c64/joy2delta.60p Normal file
View File

@ -0,0 +1,36 @@
byte joy2 @ $dc00
word delta
define read_stick routine
inputs joy2
outputs delta
trashes a, x, z, n
{
ld x, joy2
ld a, x
and a, 1 // up
if z {
copy $ffd8, delta // -40
} else {
ld a, x
and a, 2 // down
if z {
copy word 40, delta
} else {
ld a, x
and a, 4 // left
if z {
copy $ffff, delta // -1
} else {
ld a, x
and a, 8 // right
if z {
copy word 1, delta
} else {
copy word 0, delta
}
}
}
}
}