Thanks for the information. Since I'm using sdcc,I updated it to use C:
Code:
enum {
crtStatusVSync = 5, // Video is in vsync
crtStatusLightPen, // Keyboard hit
crtStatusUpdateReady, // Wrote to reg 31
};
#define VDU_VSYNC_MASK ( 1 << crtStatusVSync )
static volatile __sfr __at 0x0C CrtRegPort;
static volatile __sfr __at 0x0D CrtDataPort;
static volatile __sfr __at 0x08 VduBankPort;
// from the R6545 crt display controller manual
enum {
crtHorizontalTotalChars = 0,
crtHorizontalDisplayedChars = 1,
crtHorizontalSyncPosition = 2,
crtHorizontalVerticalSyncWidths = 3,
crtVerticalTotalRows = 4,
crtVerticalTotalLineAdjust = 5,
crtVerticalDisplayedRows = 6,
crtVerticalSyncPosition = 7,
crtModeControl = 8,
crtRowScanLines = 9,
crtCursorPositionHigh = 14,
crtCursorPositionLow,
};
///< Setup crt to 64x16 tiles and hide the cursor
void vdu_crt_setup() {
// Cursor off screen
CrtRegPort = crtCursorPositionHigh;
CrtDataPort = 0xff;
CrtRegPort = crtCursorPositionLow;
CrtDataPort = 0xff;
CrtRegPort = crtHorizontalDisplayedChars; // Columns on screen
CrtDataPort = 64;
CrtRegPort = crtVerticalDisplayedRows; // Rows on screen
CrtDataPort = 16;
CrtRegPort = crtRowScanLines; // Rows per character - cuts of the bottom of tiles
CrtDataPort = 15; // Rows - 1
}
///< Switch in vdu PCG or colour data at 0xF8000
void vdu_bank( bool colour ) __fastcall {
VduBankPort = colour ? 0x47 : 0x07;
}
///< Wait for full vblank cycle, so 1/50th of a second has passed (for timing)
void vdu_wait() {
#define VDU_STATUS_PORT 0x0C
#define VDU_VSYNC_BIT 5
__asm
crt_poll:
in a,(#VDU_STATUS_PORT)
bit #VDU_VSYNC_BIT,a
jp z, crt_poll
crt_poll_end:
in a,(#VDU_STATUS_PORT)
bit #VDU_VSYNC_BIT,a
jp nz, crt_poll_end
__endasm;
}
Support me on Patreon: https://www.patreon.com/Under4Mhz
