From e3c18cdf4b58062444f1781ae709618cbfcc9661 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 21 Jul 2024 19:25:51 -0500 Subject: [PATCH] Added DMA clear. Almost working! --- src/main.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/main.c b/src/main.c index 30419c1..da68494 100644 --- a/src/main.c +++ b/src/main.c @@ -146,6 +146,63 @@ #include "a23d2.h" +asm ( + ".text\n" +// " .cpu mosw65c02\n" +// "mos-insns-w65c02\n" +// "EF_MOS_ARCH_W65C02 \n" + ".global dmaClear\n" + "dmaClear:\n" + "pha\n" +// "phx\n" + ".byte $DA\n" + "php \n" // preserver interrupt state + c + "sei \n" // disable interrupts + "ldy 1 \n" // y = io_ctrl + //"phy \n" // save io_ctrl on stack + ".byte $5A\n" + //"stz 1 \n" // map in the dma registers, where we can get them + ".byte $64,$01 \n" + //"stz $DF00 \n" // clear dma control + ".byte $9c,$00,$DF\n" + "ldy #$05 \n" // DMA_CTRL_ENABLE+DMA_CTRL_FILL + "sty $DF00 \n" + "ldy __rc8 \n" // Fill Color + "sty $DF01 \n" // Fill value + "sta $DF08 \n" // Addr Low + "stx $DF09 \n" // Addr Hi + "lda __rc2 \n" // Addr Bank + "sta $DF0A \n" + "lda __rc4 \n" // length low + "sta $DF0C \n" + "lda __rc5 \n" // length middle + "sta $DF0D \n" + "lda __rc6 \n" // length high + "sta $DF0E \n" + "lda #$80 \n" // DMA_CTRL_START + //"tsb $DF00 \n" // DMA_CTRL + ".byte $0C,$00,$DF\n" +"wait: lda $DF01 \n" // DMA_STATUS + "bmi wait \n" // Wait for DMA + //"stz $DF00 \n" // DMA Off + ".byte $9c,$00,$DF\n" + "nop \n" + "nop \n" + "nop \n" // wait + "nop \n" + "nop \n" + "nop \n" + "pla \n" // restore the io_ctrl + "sta 1 \n" + "plp \n" +// "plx\n" + ".byte $FA\n" + "pla\n" + "rts \n" +); + +void dmaClear(uint32_t address, uint32_t length, byte color); + #if 0 typedef struct airplaneS { @@ -346,6 +403,7 @@ float collectZ = 0; + // This flight model is basically the one from "Build Your Own Flight Sim // in C++" by Michael Radtke and Chris Lampton. void lightPlane(void) { @@ -603,11 +661,17 @@ void runSimulation(void) { _drawlist = DRAWLIST_P0; } +#if 0 // Erase old scene. bitmapSetColor(0); _useColor = false; //textPrint("a23d2Draw()\n"); a23d2Draw(); +#else + + dmaClear(pageZero ? 0x6c000 : 0x58000, 0x12c00, 0); + +#endif // Draw new scene. //textPrint("a23d2Render()\n");