mirror of
https://github.com/jeremysrand/colourgo.git
synced 2024-10-31 13:07:10 +00:00
Draw a floor which moves.
This commit is contained in:
parent
df3238358a
commit
e2f97a6b5e
@ -19,6 +19,10 @@
|
||||
9DFD77D31F1F9C2500639A48 /* V2Make.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; name = V2Make.scpt; path = make/V2Make.scpt; sourceTree = "<group>"; };
|
||||
9DFD77D91F1FA47900639A48 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||
9DFD77DB1F1FA4A400639A48 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
|
||||
9DFD77DC1F1FB69600639A48 /* vbl.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = vbl.s; sourceTree = "<group>"; };
|
||||
9DFD77DD1F1FB69600639A48 /* vbl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vbl.h; sourceTree = "<group>"; };
|
||||
9DFD77DE1F1FB69600639A48 /* machine.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = machine.c; sourceTree = "<group>"; };
|
||||
9DFD77DF1F1FB69600639A48 /* machine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = machine.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
@ -35,6 +39,10 @@
|
||||
9DFD77C91F1F9C2500639A48 /* game.s */,
|
||||
9DFD77DB1F1FA4A400639A48 /* game.h */,
|
||||
9DFD77D91F1FA47900639A48 /* main.c */,
|
||||
9DFD77DC1F1FB69600639A48 /* vbl.s */,
|
||||
9DFD77DD1F1FB69600639A48 /* vbl.h */,
|
||||
9DFD77DE1F1FB69600639A48 /* machine.c */,
|
||||
9DFD77DF1F1FB69600639A48 /* machine.h */,
|
||||
9DFD77CA1F1F9C2500639A48 /* Makefile */,
|
||||
9DFD77CB1F1F9C2500639A48 /* make */,
|
||||
);
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
.export _game
|
||||
|
||||
.import _vblWait
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
|
||||
@ -218,10 +220,9 @@ LINE191 = LINE190 + 1024
|
||||
|
||||
.CODE
|
||||
|
||||
_game:
|
||||
.proc _game
|
||||
|
||||
; Set up hires screen
|
||||
|
||||
jsr clearScreen
|
||||
lda TXTCLR
|
||||
lda MIXCLR
|
||||
@ -229,16 +230,92 @@ _game:
|
||||
lda LOWSCR
|
||||
|
||||
|
||||
wait:
|
||||
ldy #150
|
||||
jsr drawLine
|
||||
ldy #155
|
||||
jsr drawLine
|
||||
|
||||
ldx #0
|
||||
@L1:
|
||||
jsr _vblWait
|
||||
ldy #151
|
||||
jsr drawGrid
|
||||
ldy #152
|
||||
jsr drawGrid
|
||||
ldy #153
|
||||
jsr drawGrid
|
||||
ldy #154
|
||||
jsr drawGrid
|
||||
inx
|
||||
cpx #7
|
||||
bne @L2
|
||||
ldx #0
|
||||
|
||||
@L2:
|
||||
lda KEYBOARD
|
||||
bpl wait
|
||||
bpl @L1
|
||||
lda STROBE
|
||||
|
||||
lda TXTSET
|
||||
|
||||
rts
|
||||
|
||||
clearScreen:
|
||||
.endproc
|
||||
|
||||
|
||||
.proc drawLine
|
||||
lda loAddrs,y
|
||||
sta ZPADDR
|
||||
lda page1HiAddrs,y
|
||||
sta ZPADDR+1
|
||||
|
||||
ldy #0
|
||||
@L1:
|
||||
lda #$55
|
||||
sta (ZPADDR),y
|
||||
iny
|
||||
lda #$2a
|
||||
sta (ZPADDR),y
|
||||
iny
|
||||
cpy #MAXXBYTE
|
||||
bne @L1
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc drawGrid
|
||||
lda loAddrs,y
|
||||
sta ZPADDR
|
||||
lda page1HiAddrs,y
|
||||
sta ZPADDR+1
|
||||
|
||||
lda violetEvenGrid,x
|
||||
sta evenVal
|
||||
lda violetOddGrid,x
|
||||
sta oddVal
|
||||
|
||||
ldy #0
|
||||
@L1:
|
||||
lda evenVal
|
||||
sta (ZPADDR),y
|
||||
iny
|
||||
lda oddVal
|
||||
sta (ZPADDR),y
|
||||
iny
|
||||
cpy #MAXXBYTE
|
||||
bne @L1
|
||||
|
||||
rts
|
||||
|
||||
; Locals
|
||||
evenVal: .BYTE $00
|
||||
oddVal: .BYTE $00
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
.proc clearScreen
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
@ -260,6 +337,8 @@ clearScreen:
|
||||
bne @L1
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.DATA
|
||||
|
||||
@ -340,3 +419,10 @@ page2HiAddrs:
|
||||
.HIBYTES LINE168+$2000, LINE169+$2000, LINE170+$2000, LINE171+$2000, LINE172+$2000, LINE173+$2000, LINE174+$2000, LINE175+$2000
|
||||
.HIBYTES LINE176+$2000, LINE177+$2000, LINE178+$2000, LINE179+$2000, LINE180+$2000, LINE181+$2000, LINE182+$2000, LINE183+$2000
|
||||
.HIBYTES LINE184+$2000, LINE185+$2000, LINE186+$2000, LINE187+$2000, LINE188+$2000, LINE189+$2000, LINE190+$2000, LINE191+$2000
|
||||
|
||||
violetEvenGrid:
|
||||
.BYTE $00, $00, $00, $40, $10, $04, $01
|
||||
|
||||
violetOddGrid:
|
||||
.BYTE $20, $08, $02, $00, $00, $00, $00
|
||||
|
||||
|
103
colourgo/machine.c
Normal file
103
colourgo/machine.c
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// machine.c
|
||||
// colourgo
|
||||
//
|
||||
// Created by Jeremy Rand on 2017-07-19.
|
||||
// Copyright © 2017 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#include <apple2.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "machine.h"
|
||||
#include "vbl.h"
|
||||
|
||||
|
||||
// Typedefs
|
||||
typedef enum {
|
||||
GS_SPEED_SLOW,
|
||||
GS_SPEED_FAST
|
||||
} tMachineGSSpeed;
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
static tMachineGSSpeed gOldSpeed = GS_SPEED_SLOW;
|
||||
|
||||
|
||||
// Implementation
|
||||
|
||||
|
||||
static bool machineIs2c(void)
|
||||
{
|
||||
switch (get_ostype()) {
|
||||
case APPLE_IIC:
|
||||
case APPLE_IIC35:
|
||||
case APPLE_IICEXP:
|
||||
case APPLE_IICREV:
|
||||
case APPLE_IICPLUS:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool machineIs2GS(void)
|
||||
{
|
||||
switch (get_ostype()) {
|
||||
case APPLE_IIGS:
|
||||
case APPLE_IIGS1:
|
||||
case APPLE_IIGS3:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static tMachineGSSpeed setGSSpeed(tMachineGSSpeed newSpeed)
|
||||
{
|
||||
uint8_t *speedRegister = (uint8_t *)0xc036;
|
||||
uint8_t value = *speedRegister;
|
||||
tMachineGSSpeed oldSpeed;
|
||||
|
||||
if ((value & 0x80) != 0)
|
||||
oldSpeed = GS_SPEED_FAST;
|
||||
else
|
||||
oldSpeed = GS_SPEED_SLOW;
|
||||
|
||||
if (oldSpeed != newSpeed) {
|
||||
if (newSpeed == GS_SPEED_FAST) {
|
||||
value |= 0x80;
|
||||
} else {
|
||||
value &= 0x7f;
|
||||
}
|
||||
*speedRegister = value;
|
||||
}
|
||||
|
||||
return oldSpeed;
|
||||
}
|
||||
|
||||
|
||||
void initMachine(void)
|
||||
{
|
||||
gVblWait = vblWaitNon2c;
|
||||
|
||||
if (machineIs2c()) {
|
||||
gVblWait = vblWait2c;
|
||||
} else if (machineIs2GS()) {
|
||||
vblInit2gs();
|
||||
gOldSpeed = setGSSpeed(GS_SPEED_SLOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void uninitMachine(void)
|
||||
{
|
||||
if (machineIs2GS()) {
|
||||
setGSSpeed(gOldSpeed);
|
||||
}
|
||||
}
|
19
colourgo/machine.h
Normal file
19
colourgo/machine.h
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// machine.h
|
||||
// colourgo
|
||||
//
|
||||
// Created by Jeremy Rand on 2017-07-19.
|
||||
// Copyright © 2017 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __colourgo__machine__
|
||||
#define __colourgo__machine__
|
||||
|
||||
|
||||
// API
|
||||
|
||||
extern void initMachine(void);
|
||||
extern void uninitMachine(void);
|
||||
|
||||
|
||||
#endif /* defined(__colourgo__machine__) */
|
@ -9,10 +9,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "game.h"
|
||||
#include "machine.h"
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
initMachine();
|
||||
game();
|
||||
uninitMachine();
|
||||
return 0;
|
||||
}
|
||||
|
32
colourgo/vbl.h
Normal file
32
colourgo/vbl.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// vbl.h
|
||||
// colourgo
|
||||
//
|
||||
// Created by Jeremy Rand on 2017-07-19.
|
||||
// Copyright © 2017 Jeremy Rand. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __colourgo__vbl__
|
||||
#define __colourgo__vbl__
|
||||
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef void (*tVblWaitFunction)(void);
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
extern tVblWaitFunction gVblWait;
|
||||
|
||||
// API
|
||||
|
||||
extern void __fastcall__ vblInit2gs(void);
|
||||
extern void __fastcall__ vblWait(void);
|
||||
extern void __fastcall__ vblWaitNon2c(void);
|
||||
extern void __fastcall__ vblWait2c(void);
|
||||
|
||||
extern void __fastcall__ vblIRQCallback(void);
|
||||
|
||||
|
||||
#endif /* defined(__colourgo__vbl__) */
|
75
colourgo/vbl.s
Normal file
75
colourgo/vbl.s
Normal file
@ -0,0 +1,75 @@
|
||||
;
|
||||
; vbl.s
|
||||
; colourgo
|
||||
;
|
||||
; Created by Jeremy Rand on 2017-07-19.
|
||||
; Copyright © 2017 Jeremy Rand. All rights reserved.
|
||||
;
|
||||
|
||||
|
||||
|
||||
.export _vblWait, _vblWaitNon2c, _vblWait2c, _vblInit2gs
|
||||
.export _gVblWait
|
||||
.interruptor _vblIRQCallback
|
||||
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
|
||||
RDVBLBAR := $C019
|
||||
|
||||
|
||||
.proc _vblWait
|
||||
jmp (_gVblWait)
|
||||
.endproc
|
||||
|
||||
.proc _vblInit2gs
|
||||
lda #$fe
|
||||
sta compType
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _vblWaitNon2c
|
||||
lda compType
|
||||
@L1:
|
||||
cmp RDVBLBAR
|
||||
bpl @L1
|
||||
@L2:
|
||||
cmp RDVBLBAR
|
||||
bmi @L2
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _vblIRQCallback
|
||||
pha
|
||||
lda #$0
|
||||
sta vbl2cByte
|
||||
pla
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.proc _vblWait2c
|
||||
lda #$ff
|
||||
sta vbl2cByte
|
||||
|
||||
@L1:
|
||||
lda vbl2cByte
|
||||
bne @L1
|
||||
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
.data
|
||||
|
||||
_gVblWait:
|
||||
.BYTE $0, $0
|
||||
|
||||
compType:
|
||||
.BYTE $7e
|
||||
|
||||
vbl2cByte:
|
||||
.BYTE $00
|
Loading…
Reference in New Issue
Block a user