1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +00:00

astrocade: more updates, flop patterns

This commit is contained in:
Steven Hugg 2019-05-31 18:15:30 -04:00
parent 700877e310
commit 9ddad79326
18 changed files with 271 additions and 185 deletions

View File

@ -102,6 +102,7 @@ TODO:
- parse .incbin directives?
- can't replace in hex directives
- should maybe use same single-canvas editor for map + char editor
- Uncaught Expected 12 bytes; image has 6 (380:13): Expected 12 bytes; image has 6 ... over and over ... editing BALL
- crt0.s compiled each time?
- debug highlight doesn't go away when debugging -> running
- show breakpoint of PC or highest address on stack

View File

@ -528,32 +528,48 @@ typedef struct {
// write pattern (E,D,C,B) magic A @ HL
void WRIT(ContextBlock *ctx) {
byte x = _E;
byte y = _D;
byte magic = _A;
byte w = _C;
byte h = _B;
byte x = _E;
byte y = _D;
byte* src = (byte*) _HL;
byte* dest = &vmagic[y][x>>2];// destination address
byte i,j;
byte magic = _A;
byte* dest = &vmagic[y][0]; // destination address
byte xb = (magic & M_FLOP) ? (39-(x>>2)) : (x>>2);
byte i,j,b;
// iterate through all lines
for (j=0; j<h; j++) {
EXIT_CLIPDEST(dest);
if ((hw_magic = magic) & M_XPAND) {
for (i=0; i<w; i++) {
byte b = *src++;
*dest++ = b;
*dest++ = b;
hw_magic = magic;
if (magic & M_XPAND) {
// when XPAND set, write twice as many bytes
for (i=0; i<w*2; i+=2) {
b = *src++;
// when FLOP set, sprite position is also mirrored
if (magic & M_FLOP) {
dest[xb-i] = b;
dest[xb-i-1] = b;
} else {
dest[xb+i] = b;
dest[xb+i+1] = b;
}
}
*dest = 0;
dest += VBWIDTH-w*2;
} else {
for (i=0; i<w; i++) {
*dest++ = *src++;
// when FLOP set, sprite position is also mirrored
if (magic & M_FLOP) {
dest[xb-i] = *src++;
} else {
dest[xb+i] = *src++;
}
*dest = 0;
dest += VBWIDTH-w;
}
}
if (magic & M_FLOP)
dest[xb-i] = 0;
else
dest[xb+i] = 0;
dest += VBWIDTH;
}
}
// write sized pattern (E,D) magic A @ HL

View File

@ -9,6 +9,9 @@ TEST = 1
BIOSStart:
di ; disable interrupts
ld HL,#0x2000
.if TEST
ld HL,#(_main)
.endif
ld A,(HL) ; A <- mem[0x2000]
cp #0x55 ; found sentinel byte? ($55)
jp Z,FoundSentinel ; yes, load program

View File

@ -64,6 +64,21 @@ _main:
.db 0x00
.dw PATERN
DO WRITR
.db 0
.db 80
.db 0x40 ;+expand
.dw PATERN
DO WRITR
.db 140
.db 70
.db 0x00|0x08 ;+expand
.dw BALL
DO WRITR
.db 0
.db 70
.db 0x40|0x08 ;flop+expand
.dw BALL
DO WRITR
.db 67
.db 80
.db 0x08|1 ;expand

View File

@ -30,7 +30,46 @@ PrgStart: DI ; Disable interrupts
DB 32 ; ... and 32 pixels from the top of the screen
DB 00001100b ; ... with no enlargement, foreground color = 11, background color = 00
DW PrgName ; ... to show string at PrgName
; call Begin Music system routine
DO ACTINT
DO BMUSIC ; START THE NATIONAL ANTHEM
DW MUSICWRK ; MUSIC STACK
DB 11111100B ; 3-VOICE (A,B,C)
DW ANTHEM ; SCORE
EXIT ; Exit interpreter mode
Loop: JP Loop ; Play infinite loop
Palettes: DB $BF,$00,$00,$00 ; Left color palette (11b, 10b, 01b, 00b)
DB $E7,$9A,$39,$19 ; Right color palette (11b, 10b, 01b, 00b)
; Music stack in RAM
MUSICWRK EQU $4E7F ; BLOCK 2
; [...]
ANTHEM: MASTER 32
VOLUME $CC,$0F ; A,B=12, C=15
NOTE3 12,G1,0,0 ; G1, 0, 0
NOTE3 12,G1,0,0 ; G1, 0, 0
NOTE3 36,C2,G1,E1 ; C2, G1, E1
NOTE3 12,D2,B1,G1 ; D2, B1, G1
NOTE3 14,E2,C2,G1 ; E2, C2, G1
NOTE3 16,F2,D2,G1 ; F2, D2, G1
NOTE3 72,G2,E2,C2 ; G2, E2, C2
;
NOTE3 14,C2,F1,A1 ; C2, F1, A1
NOTE3 16,D2,F1,A1 ; D2, F1, A1
NOTE3 54,E2,C2,A1 ; E2, C2, A1
NOTE3 18,F2,D2,G1
NOTE3 36,D2,B1,G1 ; D2, B1, G1
NOTE3 72,C2,E1,G1 ; C2, E1, G1
;
CHEERS: LEGSTA ; Cheers
MASTER 24
VOICEM 11111101B ; A,B,C & Noise
VOLUME $FF,$1F ; Max. Volume
;
PUSHN 5
L2FE8: DB 30 ; Noise
NOTE3 25,G6,60,80
DSJNZ L2FE8
LEGSTA
QUIET

View File

@ -47,6 +47,7 @@ void write_pattern(byte x, byte y, byte magic, const byte* pattern);
void display_bcd_number(byte x, byte y, byte options, const byte* number, byte extopt);
void bcdn_add(byte* dest, byte size, const byte* n);
void bcdn_sub(byte* dest, byte size, const byte* n);
byte ranged_random(byte n) __z88dk_fastcall;
// QUICK MACROS
@ -57,4 +58,11 @@ void bcdn_sub(byte* dest, byte size, const byte* n);
__asm__(".db "#horcb);\
__asm__(".db "#inmod);\
#define SYS_FILL(dest,count,val)\
__asm__("rst 0x38");\
__asm__(".db 0x1b");\
__asm__(".dw "#dest);\
__asm__(".dw "#count);\
__asm__(".db "#val);\
#endif

View File

@ -82,11 +82,11 @@ _bcdn_add:
SYSTEM BCDADD
ret
; BCDSUB arg1 size arg2
.globl _bcdn_sub
_bcdn_sub:
call load5_edca_hl
SYSTEM BCDSUB
; RANGED n
.globl _ranged_random
_ranged_random:
ld a,l
SYSTEM RANGED
ret
; BLANK w h data video-addr

122
presets/astrocade/acextra.c Normal file
View File

@ -0,0 +1,122 @@
#include <string.h>
#include "aclib.h"
#define EXIT_CLIPDEST(addr) if ((((word)addr)&0xfff) >= 0xe10) return
// clear screen and set graphics mode
void clrscr(void) {
memset(vidmem, 0, VHEIGHT*VBWIDTH); // clear page 1
}
// draw vertical line
void vline(byte x, byte y1, byte y2, byte col, byte op) {
byte* dest = &vmagic[y1][x>>2];// destination address
byte y;
hw_magic = M_SHIFT(x) | op; // set magic register
col <<= 6; // put color in high pixel
for (y=y1; y<=y2; y++) {
EXIT_CLIPDEST(dest);
*dest = col; // shift + xor color
dest += VBWIDTH; // dest address to next scanline
}
}
// render a sprite with the given graphics operation
void render_sprite(const byte* src, byte x, byte y, byte op) {
byte i;
byte w = *src++; // get width from 1st byte of sprite
byte h = *src++; // get height from 2nd byte of sprite
byte* dest = &vmagic[y][x>>2];// destination address
hw_magic = M_SHIFT(x) | op; // set magic register
// y clipping off bottom
if (y+h >= VHEIGHT) {
if (y >= VHEIGHT) return;
h = VHEIGHT-y;
}
// memory copy loop
if (op != M_ERASE) {
while (h--) {
for (i=0; i<w; i++) {
*dest++ = *src++; // copy bytes
}
*dest = 0; // rest of shifted byte
dest += VBWIDTH-w; // dest address to next scanline
}
// erase sprite loop
} else {
while (h--) {
memset(dest, 0, w+1); // erase bytes
dest += VBWIDTH; // dest address to next scanline
}
}
}
// FONT FUNCTIONS
const char FONT[HICHAR-LOCHAR+1][FONT_HEIGHT*FONT_BWIDTH] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x20,0x20,0x20,0x00,0x20, },{ 0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x50,0xF8,0x50,0xF8,0x50, },{ 0x00,0x00,0x00,0xF8,0xA0,0xF8,0x28,0xF8, },{ 0x00,0x00,0x00,0xC8,0xD0,0x20,0x58,0x98, },{ 0x00,0x00,0x00,0xE0,0xA8,0xF8,0x90,0xF8, },{ 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00, },{ 0x00,0x00,0x30,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x20,0xA8,0x70,0xA8,0x20, },{ 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xE8,0x88,0xF8, },{ 0x00,0x00,0x00,0x10,0x30,0x50,0x10,0x10, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x38,0x48,0x88,0xF8,0x08, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0x10,0x20,0x40, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x08,0x10,0x20,0x40,0x20,0x10, },{ 0x00,0x00,0x00,0x00,0xF8,0x00,0xF8,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x08,0x10,0x20, },{ 0x00,0x00,0x00,0xF8,0x08,0x78,0x00,0x60, },{ 0x00,0x00,0x00,0xF8,0xA8,0xB8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08, },{ 0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10, },{ 0x00,0x00,0x00,0x20,0x50,0x88,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0xE0,0x20,0x20, },{ 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0xE0,0x20,0x20,0x38,0x20,0x20, },{ 0x00,0x00,0x00,0xE8,0xB8,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },};
// draw a letter
void draw_char(byte ch, byte x, byte y, byte op) {
const byte* src = &FONT[(ch-LOCHAR)][0];
byte* dest = &vmagic[y][x>>2]; // destination address
hw_magic = M_SHIFT(x) | M_XPAND | op;
for (byte i=0; i<8; i++) {
char b = *src++;
EXIT_CLIPDEST(dest);
*dest++ = b; // expand lower nibble -> 1st byte
*dest++ = b; // expand upper nibble -> 2nd byte
if (x & 3) {
*dest++ = 0; // leftover -> 3rd byte
*dest = 0; // reset upper/lower flag
} else {
dest++;
}
dest += VBWIDTH-3; // we incremented 3 bytes for this line
}
}
void draw_string(byte x, byte y, byte options, const char* str) {
hw_xpand = XPAND_COLORS(0, options);
do {
byte ch = *str++;
if (!ch) break;
draw_char(ch, x, y, M_XOR);
x += 8;
} while (1);
}
void draw_bcd_word(word bcd, byte x, byte y, byte op) {
byte j;
x += 3*8;
for (j=0; j<4; j++) {
draw_char('0'+(bcd&0xf), x, y, op);
x -= 8;
bcd >>= 4;
}
}
// add two 16-bit BCD values
word bcd_add(word a, word b) __naked {
a; b; // to avoid warning
__asm
push ix
ld ix,#0
add ix,sp
ld a,4 (ix)
add a, 6 (ix)
daa
ld c,a
ld a,5 (ix)
adc a, 7 (ix)
daa
ld b,a
ld l, c
ld h, b
pop ix
ret
__endasm;
}

View File

@ -0,0 +1,19 @@
#ifndef _ACEXTRA_H
#define _ACEXTRA_H
#include "aclib.h"
void clrscr();
void vline(byte x, byte y1, byte y2, byte col, byte op);
void pixel(byte x, byte y, byte col, byte op);
void render_sprite(const byte* src, byte x, byte y, byte op);
void draw_char(byte ch, byte x, byte y, byte op);
void draw_string(byte x, byte y, byte options, const char* str);
void draw_bcd_word(word bcd, byte x, byte y, byte op);
word bcd_add(word a, word b);
#define pixel(x,y,color,op) vline(x, y, y, color, op);
#define erase_sprite(src,x,y) render_sprite(src,x,y,M_ERASE);
#endif

View File

@ -2,13 +2,6 @@
#include <string.h>
#include "aclib.h"
#define EXIT_CLIPDEST(addr) if ((((word)addr)&0xfff) >= 0xe10) return
// clear screen and set graphics mode
void clrscr(void) {
memset(vidmem, 0, VHEIGHT*VBWIDTH); // clear page 1
}
// set entire palette at once (8 bytes to port 0xb)
// bytes in array should be in reverse
void set_palette(byte palette[8]) __z88dk_fastcall {
@ -31,113 +24,3 @@ __asm
__endasm;
}
// draw vertical line
void vline(byte x, byte y1, byte y2, byte col, byte op) {
byte* dest = &vmagic[y1][x>>2];// destination address
byte y;
hw_magic = M_SHIFT(x) | op; // set magic register
col <<= 6; // put color in high pixel
for (y=y1; y<=y2; y++) {
EXIT_CLIPDEST(dest);
*dest = col; // shift + xor color
dest += VBWIDTH; // dest address to next scanline
}
}
// render a sprite with the given graphics operation
void render_sprite(const byte* src, byte x, byte y, byte op) {
byte i;
byte w = *src++; // get width from 1st byte of sprite
byte h = *src++; // get height from 2nd byte of sprite
byte* dest = &vmagic[y][x>>2];// destination address
hw_magic = M_SHIFT(x) | op; // set magic register
// y clipping off bottom
if (y+h >= VHEIGHT) {
if (y >= VHEIGHT) return;
h = VHEIGHT-y;
}
// memory copy loop
if (op != M_ERASE) {
while (h--) {
for (i=0; i<w; i++) {
*dest++ = *src++; // copy bytes
}
*dest = 0; // rest of shifted byte
dest += VBWIDTH-w; // dest address to next scanline
}
// erase sprite loop
} else {
while (h--) {
memset(dest, 0, w+1); // erase bytes
dest += VBWIDTH; // dest address to next scanline
}
}
}
// FONT FUNCTIONS
const char FONT[HICHAR-LOCHAR+1][FONT_HEIGHT*FONT_BWIDTH] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x20,0x20,0x20,0x00,0x20, },{ 0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x50,0xF8,0x50,0xF8,0x50, },{ 0x00,0x00,0x00,0xF8,0xA0,0xF8,0x28,0xF8, },{ 0x00,0x00,0x00,0xC8,0xD0,0x20,0x58,0x98, },{ 0x00,0x00,0x00,0xE0,0xA8,0xF8,0x90,0xF8, },{ 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00, },{ 0x00,0x00,0x30,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x20,0xA8,0x70,0xA8,0x20, },{ 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xE8,0x88,0xF8, },{ 0x00,0x00,0x00,0x10,0x30,0x50,0x10,0x10, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x38,0x48,0x88,0xF8,0x08, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0x10,0x20,0x40, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x08,0x10,0x20,0x40,0x20,0x10, },{ 0x00,0x00,0x00,0x00,0xF8,0x00,0xF8,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x08,0x10,0x20, },{ 0x00,0x00,0x00,0xF8,0x08,0x78,0x00,0x60, },{ 0x00,0x00,0x00,0xF8,0xA8,0xB8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08, },{ 0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10, },{ 0x00,0x00,0x00,0x20,0x50,0x88,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0xE0,0x20,0x20, },{ 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0xE0,0x20,0x20,0x38,0x20,0x20, },{ 0x00,0x00,0x00,0xE8,0xB8,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },};
// draw a letter
void draw_char(byte ch, byte x, byte y, byte op) {
const byte* src = &FONT[(ch-LOCHAR)][0];
byte* dest = &vmagic[y][x>>2]; // destination address
hw_magic = M_SHIFT(x) | M_XPAND | op;
for (byte i=0; i<8; i++) {
char b = *src++;
EXIT_CLIPDEST(dest);
*dest++ = b; // expand lower nibble -> 1st byte
*dest++ = b; // expand upper nibble -> 2nd byte
if (x & 3) {
*dest++ = 0; // leftover -> 3rd byte
*dest = 0; // reset upper/lower flag
} else {
dest++;
}
dest += VBWIDTH-3; // we incremented 3 bytes for this line
}
}
void draw_string(byte x, byte y, byte options, const char* str) {
hw_xpand = XPAND_COLORS(0, options);
do {
byte ch = *str++;
if (!ch) break;
draw_char(ch, x, y, M_XOR);
x += 8;
} while (1);
}
void draw_bcd_word(word bcd, byte x, byte y, byte op) {
byte j;
x += 3*8;
for (j=0; j<4; j++) {
draw_char('0'+(bcd&0xf), x, y, op);
x -= 8;
bcd >>= 4;
}
}
// add two 16-bit BCD values
word bcd_add(word a, word b) __naked {
a; b; // to avoid warning
__asm
push ix
ld ix,#0
add ix,sp
ld a,4 (ix)
add a, 6 (ix)
daa
ld c,a
ld a,5 (ix)
adc a, 7 (ix)
daa
ld b,a
ld l, c
ld h, b
pop ix
ret
__endasm;
}

View File

@ -79,18 +79,7 @@ byte __at (0x4000) vidmem[VTOTAL][VBWIDTH];
/// GRAPHICS FUNCTIONS
void clrscr();
void set_palette(byte palette[8]) __z88dk_fastcall; // palette in reverse order
void set_sound_registers(byte regs[8]) __z88dk_fastcall; // in reverse too
void vline(byte x, byte y1, byte y2, byte col, byte op);
void pixel(byte x, byte y, byte col, byte op);
void render_sprite(const byte* src, byte x, byte y, byte op);
void draw_char(byte ch, byte x, byte y, byte op);
void draw_string(byte x, byte y, byte options, const char* str);
void draw_bcd_word(word bcd, byte x, byte y, byte op);
word bcd_add(word a, word b);
#define pixel(x,y,color,op) vline(x, y, y, color, op);
#define erase_sprite(src,x,y) render_sprite(src,x,y,M_ERASE);
#endif

View File

@ -9,6 +9,8 @@
#include "aclib.h"
//#link "aclib.c"
#include "acextra.h"
//#link "acextra.c"
//#link "hdr_autostart.s"

View File

@ -33,16 +33,16 @@ byte bcdnum[3] = {0x56,0x34,0x12};
byte bcdinc[3] = {0x01,0x00,0x00};
void main(void) {
// clear screen
clrscr();
// setup palette
set_palette(palette);
// set screen height
// set horizontal color split (position / 4)
// set interrupt status
SYS_SETOUT(89*2, 23, 0);
// clear screen
SYS_FILL(0x4000, 89*2, 0);
// display standard characters
display_string(2, 2, OPT_ON(1), "HELLO, WORLD!!");
display_string(2, 2, OPT_ON(1), "HELLO, WORLD!\xb1\xb2\xb3\xb4\xb5");
// 2x2 must have X coordinate multiple of 2
display_string(4, 16, OPT_2x2|OPT_ON(2), "BIG TEXT!");
// 4x4 must have X coordinate multiple of 4

View File

@ -1,6 +1,9 @@
#include "aclib.h"
//#link "aclib.c"
#include "acbios.h"
#include "acextra.h"
//#link "acextra.c"
//#link "hdr_autostart.s"
#include <stdlib.h>
@ -28,17 +31,10 @@ const byte palette[8] = {
0x07, 0xD4, 0x35, 0x00,
};
void setup_registers() {
set_palette(palette);
// horizontal palette split
hw_horcb = 20;
// height of screen
hw_verbl = VHEIGHT*2;
}
void main() {
setup_registers();
clrscr();
set_palette(palette);
SYS_SETOUT(89*2, 20, 0);
SYS_FILL(0x4000, 89*2, 0);
hw_xpand = XPAND_COLORS(0, 2);
draw_string(2, 80, 0, "Hello, Lines!");
draw_line(0, 0, 159, 95, 1);

View File

@ -3,6 +3,10 @@
#include "aclib.h"
//#link "aclib.c"
#include "acbios.h"
//#link "acbios.c"
#include "acextra.h"
//#link "acextra.c"
//#link "hdr_autostart.s"
const byte player_bitmap[] =
@ -14,18 +18,13 @@ const byte palette[8] = {
0x07, 0xD4, 0x35, 0x01,
};
void setup_registers() {
set_palette(palette);
hw_horcb = 0;
hw_verbl = 102*2;
}
void main() {
byte x,y;
x=10;
y=10;
setup_registers();
clrscr();
set_palette(palette);
SYS_SETOUT(102*2, 0, 0);
SYS_FILL(0x4000, 89*2, 0);
while (1) {
render_sprite(player_bitmap, x, y, M_MOVE);
erase_sprite(player_bitmap, x, y);

View File

@ -4,9 +4,9 @@
//#resource "astrocade.inc"
#include "aclib.h"
//#link "aclib.c"
//#link "hdr_autostart.s"
#include "acbios.h"
//#link "acbios.s"
//#link "hdr_autostart.s"
const byte player_bitmap[] =
{0,0, // X, Y offset
@ -20,18 +20,13 @@ const byte palette[8] = {
0x07, 0xD4, 0x33, 0x01,
};
void setup_registers() {
set_palette(palette);
hw_horcb = 0;
hw_verbl = 102*2;
}
void main() {
byte x,y;
x=20;
y=20;
setup_registers();
clrscr();
set_palette(palette);
SYS_SETOUT(98*2, 0, 0x0);
SYS_FILL(0x4000, 98*40, 0); // clear screen
activate_interrupts();
while (1) {
write_relative(x, y, M_MOVE, player_bitmap);

View File

@ -136,12 +136,11 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
v = v2;
// flop
if (magicop & 0x40) {
var v2 = 0;
for (var i=0; i<4; i++) {
v2 |= (v & 3) << (6-i*2);
v >>= 2;
}
v = v2;
v =
((v & 0x03) << 6) |
((v & 0x0c) << 2) |
((v & 0x30) >> 2) |
((v & 0xc0) >> 6);
}
// or/xor
if (magicop & 0x30) {
@ -435,6 +434,7 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
reset() {
cpu.reset();
cpu.setTstates(0);
psg.reset();
// TODO?
magicop = xpand = inmod = inlin = infbk = shift2 = horcb = 0;
verbl = sheight;

View File

@ -2027,7 +2027,6 @@ function executeBuildSteps() {
ls.files = ls.files.concat(linkstep.files);
ls.args = ls.args.concat(linkstep.args);
}
console.log(ls);
linkstep = null;
break;
}