Created
          June 23, 2019 16:42 
        
      - 
      
- 
        Save JettMonstersGoBoom/67bbadc8322d8f7536bc3af3c8b29a96 to your computer and use it in GitHub Desktop. 
    MillFork C64 sample
  
        
  
    
      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
    
  
  
    
  | const pointer screen_out = $5c00 | |
| const pointer chars_out = $6000 | |
| const pointer sprites_out = $4000 | |
| const pointer spritepointer = screen_out+$3f8 | |
| byte timer | |
| byte frameoffset | |
| void main () { | |
| vic_cr1 = $9b | |
| vic_cr2 = $c8 | |
| vic_mem = $78 | |
| vic_bg_color0 = medium_grey | |
| vic_bg_color1 = black | |
| vic_bg_color2 = white | |
| vic_spr_color1 = black | |
| vic_spr_color2 = white | |
| vic_bank_4000() | |
| vic_border = black | |
| vic_enable_multicolor() | |
| vic_spr_ena = $ff | |
| vic_spr_mcolor = $ff | |
| timer = 1 | |
| disable_irq() | |
| init_screen() | |
| main_loop() | |
| } | |
| void init_screen() { | |
| byte a | |
| byte i | |
| pointer p | |
| pointer screen | |
| pointer color | |
| pointer chrs | |
| byte page_count | |
| p = chars_out | |
| chrs = chr | |
| for page_count,0,until,8 { | |
| for i,0,until,256 { | |
| p[i] = chrs[i] | |
| } | |
| p.hi += 1 | |
| chrs.hi += 1 | |
| } | |
| p = sprites_out | |
| chrs = sprites | |
| for page_count,0,until,8 { | |
| for i,0,until,256 { | |
| p[i] = chrs[i] | |
| } | |
| p.hi += 1 | |
| chrs.hi += 1 | |
| } | |
| screen = screen_out | |
| color = c64_color_ram | |
| p = map | |
| for page_count,0,until,4 { | |
| for i,0,until,256 { | |
| a = p[i] | |
| screen[i] = a | |
| color[i] = attr[a]&$f | |
| } | |
| p.hi += 1 | |
| screen.hi += 1 | |
| color.hi += 1 | |
| } | |
| } | |
| void main_loop() { | |
| while true { | |
| while vic_raster != $ea {} | |
| while vic_raster != $FF {} | |
| vic_border -= 1 | |
| timer -=1 | |
| if timer == 0 { | |
| timer = 16 | |
| frameoffset += 1 | |
| frameoffset &= 1 | |
| copySprites() | |
| } | |
| vic_border += 1 | |
| } | |
| } | |
| array SpriteXh = [0,0,0,0,0,0,0,0] | |
| array SpriteXl = [$60,$80,$b0,$a0,$d0,$c0,$a0,$c0] | |
| array SpriteY = [10*8,8*8,7*8,12*8,11*8,22*8,20*8,18*8] | |
| array SpriteID = [0,2,4,8,8,10,12,8] | |
| array SpriteCol = [$5,$5,$5,$a,$a,$a,$a,$a] | |
| asm void copySprites() { | |
| ldx #$07 | |
| ldy #$0e | |
| setspritepositionsloop: | |
| lda SpriteXl,x | |
| sta vic_spr0_x,y | |
| lda SpriteXh,x | |
| ror | |
| rol vic_spr_hi_x | |
| lda SpriteY,x | |
| sta vic_spr0_y,y | |
| clc | |
| lda SpriteID,x | |
| adc frameoffset | |
| sta spritepointer,x | |
| lda SpriteCol,x | |
| sta vic_spr0_color,x | |
| dey | |
| dey | |
| dex | |
| bpl setspritepositionsloop | |
| rts | |
| } | |
| array map = file("data/map.bin") | |
| array attr = file("data/attr.bin") | |
| array sprites = file("data/sprites.bin") | |
| array chr = file("data/chr.bin") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment