aboutsummaryrefslogtreecommitdiff
path: root/int.h
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-05-03 08:21:10 +0100
committerJuan J. Martinez <jjm@usebox.net>2021-05-03 10:00:00 +0100
commitc3b0fa04a663fe233765b83d3be41a42aa08c25d (patch)
tree0befda349001ef6ce306b39378f9c70ad917363e /int.h
downloadreturn-of-traxtor-cpc-main.tar.gz
return-of-traxtor-cpc-main.zip
Initial import for public releaseHEADmain
Diffstat (limited to 'int.h')
-rw-r--r--int.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/int.h b/int.h
new file mode 100644
index 0000000..3932071
--- /dev/null
+++ b/int.h
@@ -0,0 +1,100 @@
+/*
+ The Return of Traxtor (Amstrad CPC)
+ Copyright (C) 2015 Juan J. Martinez <jjm@usebox.net>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#ifndef _INT_H
+#define _INT_H
+
+#ifndef WFRAMES
+#define WFRAMES 4
+#endif
+
+// timer
+unsigned char tick;
+unsigned char timer;
+unsigned char playerISR;
+
+void
+wait()
+{
+ while ((unsigned char)(tick - timer) < WFRAMES)
+ __asm__("halt");
+ timer = tick;
+}
+
+void
+WyzPlayerOn()
+{
+ __asm;
+ di
+ ld a, #1
+ ld (_playerISR), a
+ ei
+ __endasm;
+}
+
+void
+WyzPlayerOff()
+{
+ __asm;
+ di
+ xor a
+ ld (_playerISR), a
+ call _cpc_WyzSetPlayerOff
+ ei
+ __endasm;
+
+}
+
+void
+setup_int()
+{
+ tick = 0;
+ timer = 0;
+ playerISR = 0;
+ __asm;
+ di
+
+ ld ix, #0x0038
+ ld hl, #isr
+ ld (ix), #0xc3
+ ld 1(ix), l
+ ld 2(ix), h
+ im 1
+
+ ei
+ jp setup_done
+
+ isr:
+ push af
+ ld a, (#_tick)
+ inc a
+ ld (#_tick), a
+ ld a, (#_playerISR)
+ or a
+ jp z, player_is_off
+
+ jp _cpc_WyzPlayerISR
+ player_is_off:
+ pop af
+ ei
+ ret
+
+ setup_done:
+ __endasm;
+}
+
+#endif // _INT_H