#include #include "aclib.h" #include "acextra.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>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; }