diff --git a/HISTORY.md b/HISTORY.md index 2ed6a2d..48ea5db 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 ---- diff --git a/TODO.md b/TODO.md index c1c39c0..7b08e56 100644 --- a/TODO.md +++ b/TODO.md @@ -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 ----------- diff --git a/eg/c64/demo-game/demo-game.60p b/eg/c64/demo-game/demo-game.60p index b97a479..027f2cc 100644 --- a/eg/c64/demo-game/demo-game.60p +++ b/eg/c64/demo-game/demo-game.60p @@ -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. diff --git a/eg/c64/joystick.60p b/eg/c64/joystick.60p index fdbaa83..0558426 100644 --- a/eg/c64/joystick.60p +++ b/eg/c64/joystick.60p @@ -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 diff --git a/include/c64/joy2delta.60p b/include/c64/joy2delta.60p new file mode 100644 index 0000000..ff1b583 --- /dev/null +++ b/include/c64/joy2delta.60p @@ -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 + } + } + } + } +}