Created
January 13, 2022 18:17
-
-
Save JettMonstersGoBoom/dca27eb4ba4b0fd5c24ec5f481a0d0dc to your computer and use it in GitHub Desktop.
REU millfork experiments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import c64_joy | |
| volatile byte REU_STATUS @$DF00 | |
| const byte REU_IRQ = $80 //Bit 7: INTERRUPT PENDING (1 = interrupt waiting to be served) | |
| const byte REU_EOB = $40 //Bit 6: END OF BLOCK (1 = transfer complete) | |
| const byte REU_FAULT = $20 //Bit 5: FAULT (1 = block verify error) | |
| const byte REU_VERSION = %1111 | |
| volatile byte REU_COMMAND @$DF01 | |
| //Bit 7: EXECUTE (1 = transfer per current configuration) | |
| //This bit must be set to execute a command. | |
| const byte REU_EXECUTE = $80 | |
| //Bit 6: reserved (normally 0) | |
| const byte REU_AUTOLOAD = (1<<5) | |
| //Bit 5: LOAD (1 = enable autoload option) | |
| //With autoload enabled the address and length registers (see | |
| //below) will be unchanged after a command execution. | |
| //Otherwise the address registers will be counted up to the | |
| //address off the last accessed byte of a DMA + 1, | |
| //and the length register will be changed (normally to 1). | |
| const byte REU_TRIGGERONCOMMAND = (1<<4) | |
| //Bit 4: $FF00 | |
| //If this bit is set command execution starts immediately | |
| //after setting the command register. | |
| //Otherwise command execution is delayed until write access to | |
| //memory position $FF00 | |
| //Bits 3 - 2: reserved (normally 0) | |
| const byte REU_RAMtoREU = 0 | |
| const byte REU_REUtoRAM = 1 | |
| const byte REU_SWAP = 2 | |
| const byte REU_COMPARE = 3 | |
| //Bits 1 - 0: TRANSFER TYPE | |
| //00 = transfer C128 -> REU | |
| //01 = transfer REU -> C128 | |
| //10 = swap C128 <-> REU | |
| //11 = compare C128 - REU | |
| volatile word REU_RAM_ADDRESS @$DF02 | |
| volatile int24 REU_ADDRESS @$DF04 | |
| volatile word REU_LENGTH @$DF07 | |
| const word SCREEN_STEP = 40 | |
| const word BITMAP_STEP = 320 | |
| const word SCREEN_IN_STEP = (40*6) | |
| const word BITMAP_IN_STEP = (320*6) | |
| const int24 SCREEN_LOC = (BITMAP_IN_STEP*24)*2 | |
| const int24 COLOR_LOC = SCREEN_LOC + ((SCREEN_IN_STEP*24)*2) | |
| array(int24) bitmap_lines[256] @$8000 | |
| array(int24) screen_lines[256] | |
| void main() { | |
| byte line,xl | |
| word tick,ytick | |
| word ty,tx | |
| word lty,ltx | |
| int24 bitmap_address | |
| int24 screen_address | |
| int24 color_address | |
| pointer screen_out_address | |
| pointer bitmap_out_address | |
| pointer color_out_address | |
| int24 work_24,work_s_24 | |
| tick = 0 | |
| asm | |
| { | |
| sei | |
| } | |
| work_24 = 0 | |
| work_s_24 = 0 | |
| for line,0,until,255 { | |
| bitmap_lines[line]=work_24 | |
| work_24+=BITMAP_IN_STEP | |
| screen_lines[line]=work_s_24 | |
| work_s_24+=SCREEN_IN_STEP | |
| } | |
| vic_border = 0 | |
| vic_bg_color0=0 | |
| BlitMap(0,0) | |
| vic_38_columns() | |
| vic_enable_bitmap() | |
| vic_bank_4000() | |
| vic_bitmap_2000() | |
| vic_enable_multicolor() | |
| c64_ram_io() | |
| vic_bg_color0=0 | |
| ltx = 32 | |
| lty = 32 | |
| tick = 0 | |
| ytick =0 | |
| while(true) | |
| { | |
| while (vic_raster!=$f9) {} | |
| vic_set_scroll(7-(tick.lo&7),7-(ytick.lo&7)) | |
| vic_border=1 | |
| tx = tick>>3 | |
| ty = ytick>>3 | |
| if (ltx!=tx) || (lty!=ty) { | |
| ltx = tx | |
| lty = ty | |
| bitmap_address = (tick&0xfff8) | |
| work_24 = bitmap_lines[ty] | |
| bitmap_address+=work_24 | |
| bitmap_out_address = $6000 | |
| work_24 = screen_lines[ty] | |
| screen_address = SCREEN_LOC | |
| screen_address += work_24 | |
| screen_address+= tx | |
| color_address = COLOR_LOC | |
| color_address+= tx | |
| color_address += work_24 | |
| screen_out_address = $4400 | |
| color_out_address = $d800 | |
| for line,0,until,23 { | |
| REU_ADDRESS = bitmap_address | |
| REU_RAM_ADDRESS = bitmap_out_address | |
| REU_LENGTH = BITMAP_STEP | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_REUtoRAM | REU_AUTOLOAD | |
| REU_ADDRESS = screen_address | |
| REU_RAM_ADDRESS = screen_out_address | |
| REU_LENGTH = 40 | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_REUtoRAM | REU_AUTOLOAD | |
| REU_ADDRESS = color_address | |
| REU_RAM_ADDRESS = color_out_address | |
| REU_LENGTH = 40 | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_REUtoRAM | REU_AUTOLOAD | |
| screen_address+=SCREEN_IN_STEP | |
| screen_out_address+=SCREEN_STEP | |
| color_address+=SCREEN_IN_STEP | |
| color_out_address+=SCREEN_STEP | |
| bitmap_address+=BITMAP_IN_STEP | |
| bitmap_out_address+=BITMAP_STEP | |
| } | |
| } | |
| vic_border=2 | |
| read_joy2() | |
| tick+=input_dx | |
| ytick+=input_dy | |
| vic_border=0 | |
| } | |
| } | |
| const array META_BLOCKS = file("data/map/levl1 - Tiles.bin") | |
| const array CELL_BLOCKS = file("data/map/levl1 - Chars.bin") | |
| const array ATRL1_BLOCKS = file("data/map/levl1 - CharAttribs_L1.bin") | |
| const array ATRL2_BLOCKS = file("data/map/levl1 - CharAttribs_L2.bin") | |
| const array MAP_DATA = file("data/map/levl1 - Map (32x32).bin") | |
| array attrib_buffer[16] | |
| array cattrib_buffer[16] | |
| void BlitBlock(byte x,byte y,byte block) | |
| { | |
| pointer source | |
| pointer dest,cdest | |
| pointer metasource | |
| int24 reu_dest,reu_cdest | |
| word wword | |
| byte tx,ty,tz | |
| wword = x | |
| wword <<= 3 | |
| reu_dest = bitmap_lines[y] | |
| // dest = y | |
| // dest *= BITMAP_IN_STEP | |
| reu_dest += wword | |
| // dest += $2000 | |
| metasource = block | |
| metasource <<=4 | |
| metasource+=META_BLOCKS | |
| tz=0 | |
| for ty,0,until,4 { | |
| REU_ADDRESS = reu_dest | |
| for tx,0,until,4 { | |
| source = metasource[tz] | |
| attrib_buffer[tz] = ATRL2_BLOCKS[source] | |
| cattrib_buffer[tz] = ATRL1_BLOCKS[source] | |
| source <<=3 | |
| source += CELL_BLOCKS | |
| REU_RAM_ADDRESS = source | |
| REU_LENGTH = 8 | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_RAMtoREU | |
| tz+=1 | |
| } | |
| reu_dest+=BITMAP_IN_STEP | |
| } | |
| reu_dest = x | |
| for ty,0,until,y { | |
| reu_dest+=SCREEN_IN_STEP | |
| } | |
| reu_cdest = reu_dest | |
| reu_cdest+=COLOR_LOC | |
| reu_dest+= SCREEN_LOC | |
| source = attrib_buffer.addr | |
| dest = cattrib_buffer.addr | |
| tz = 0 | |
| for ty,0,until,4 { | |
| REU_ADDRESS = reu_dest | |
| REU_RAM_ADDRESS = source | |
| REU_LENGTH = 4 | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_RAMtoREU | |
| REU_ADDRESS = reu_cdest | |
| REU_RAM_ADDRESS = dest | |
| REU_LENGTH = 4 | |
| REU_COMMAND = REU_EXECUTE | REU_TRIGGERONCOMMAND | REU_RAMtoREU | |
| source+=4 | |
| dest +=4 | |
| reu_dest+=SCREEN_IN_STEP | |
| reu_cdest+=SCREEN_IN_STEP | |
| } | |
| } | |
| void BlitMap(byte xo,byte yo) | |
| { | |
| byte tx,ty | |
| word tz | |
| tz = 0 | |
| for ty,0,until,12 { | |
| for tx,0,until,30 { | |
| BlitBlock(tx<<2,ty<<2,MAP_DATA[tz+tx]) | |
| } | |
| tz+=32 | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment