asm
  ld sp,$6BFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $6010
dim seed as uinteger at $6012
dim ee0 as uinteger at $6018
dim ee1 as uinteger at $601A
dim ee2 as uinteger at $6014
dim ee3 as uinteger at $6016
dim ex0 as uinteger at $6020
dim ey0 as uinteger at $6022
dim ej0 as uinteger at $6024
dim ej1 as uinteger at $6026

seed=0

sub donkeykongputchar(txpos as uinteger,typos as uinteger,tchr as ubyte):
  poke ($7400+typos+(txpos*32))bxor %1111100000,tchr
  end sub

for ee0=0 to 31
  for ee1=2 to 29
    seed=smsrnd(seed)
    donkeykongputchar(ee1,ee0,$60+(seed mod 9))
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    donkeykongputchar(ee1+13,ee0+15,ee0*16+ee1)
    next:next

eee=0:ex0=8:ey0=8
do

donkeykongputchar(3,1,48+(int(eee/10000) mod 10))
donkeykongputchar(4,1,48+(int(eee/1000) mod 10))
donkeykongputchar(5,1,48+(int(eee/100) mod 10))
donkeykongputchar(6,1,48+(int(eee/10) mod 10))
donkeykongputchar(7,1,48+(eee mod 10))

ee0=peek($7C00)
donkeykongputchar(5,3,48+(int(ee0/100) mod 10))
donkeykongputchar(6,3,48+(int(ee0/10) mod 10))
donkeykongputchar(7,3,48+(ee0 mod 10))

ee1=peek($7C80)
donkeykongputchar(5,4,48+(int(ee1/100) mod 10))
donkeykongputchar(6,4,48+(int(ee1/10) mod 10))
donkeykongputchar(7,4,48+(ee1 mod 10))

ex0=ex0+((ee0 band 1)/1)-((ee0 band 2)/2)
ey0=ey0+((ee0 band 8)/8)-((ee0 band 4)/4)
donkeykongputchar(ex0,ey0,32+(eee mod 64))

eee=eee+1
loop



do:loop


do
for eee=$7400 to $77FF 'video
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next
loop



do
for eee=$7000 to $73FF 'sprites
  seed=smsrnd(seed)
  poke eee,seed
  next

for eee=$7400 to $77FF 'video
  seed=smsrnd(seed)
  poke eee,seed
  next
loop

do:loop

'static ADDRESS_MAP_START( dkong_map, AS_PROGRAM, 8, dkong_state )
'AM_RANGE(0x0000, 0x3fff) AM_ROM
'AM_RANGE(0x6000, 0x6bff) AM_RAM
'AM_RANGE(0x7000, 0x73ff) AM_RAM AM_SHARE("sprite_ram") /* sprite set 1 */
'AM_RANGE(0x7400, 0x77ff) AM_RAM_WRITE(dkong_videoram_w) AM_SHARE("video_ram")
'AM_RANGE(0x7800, 0x780f) AM_DEVREADWRITE("dma8257", i8257_device, read, write)   /* P8257 control registers */
'AM_RANGE(0x7c00, 0x7c00) AM_READ_PORT("IN0") AM_LATCH8_WRITE("ls175.3d")    /* IN0, sound CPU intf */
'AM_RANGE(0x7c80, 0x7c80) AM_READ_PORT("IN1") AM_WRITE(radarscp_grid_color_w)/* IN1 */
'AM_RANGE(0x7d00, 0x7d00) AM_READ(dkong_in2_r)                               /* IN2 */
'AM_RANGE(0x7d00, 0x7d07) AM_DEVWRITE("ls259.6h", latch8_device, bit0_w)          /* Sound signals */
'AM_RANGE(0x7d80, 0x7d80) AM_READ_PORT("DSW0") AM_WRITE(dkong_audio_irq_w)   /* DSW0 */
'AM_RANGE(0x7d81, 0x7d81) AM_WRITE(radarscp_grid_enable_w)
'AM_RANGE(0x7d82, 0x7d82) AM_WRITE(dkong_flipscreen_w)
'AM_RANGE(0x7d83, 0x7d83) AM_WRITE(dkong_spritebank_w)                       /* 2 PSL Signal */
'AM_RANGE(0x7d84, 0x7d84) AM_WRITE(nmi_mask_w)
'AM_RANGE(0x7d85, 0x7d85) AM_WRITE(p8257_drq_w)          /* P8257 ==> /DRQ0 /DRQ1 */
'AM_RANGE(0x7d86, 0x7d87) AM_WRITE(dkong_palettebank_w)
'ADDRESS_MAP_END



'
'sub chacknpopputchar(txpos as uinteger,typos as uinteger,tchr as ubyte):
'  poke $9000+txpos+(typos*32),tchr
'  end sub
'
'sub chacknpopputsprite(tlayer as uinteger,txpos as ubyte,typos as ubyte,tid as ubyte,tclut as ubyte):
'  poke $9840+(tlayer*4),typos bxor $FF
'  poke $9841+(tlayer*4),tid
'  poke $9842+(tlayer*4),tclut
'  poke $9843+(tlayer*4),txpos
'  end sub
'
'
''-------------------------------------------------------------------------------
'
'for ee2=0 to 31
'  for ee3=0 to 31
'    chacknpopputchar(ee3,ee2,code("."))
'    next:next
'
'for ee2=0 to 15
'  for ee3=0 to 15
'    chacknpopputchar(ee3+14,ee2+12,ee3+(ee2*16))
'    next:next
'
'for eee=$9800 to $983F '- attr  64 bytes - ?????????????
'  for ee2=1 to 1000:next
'  seed=smsrnd(seed)
'  poke eee,seed
'  next
'
'for eee=$9840 to $98FF '- sprites - 192 bytes
'  poke eee,eee
'  next
'
'ex0=40:ey0=40
'eee=0
'
'do
'  ej0=peek($8809) bxor $FF
'  ej1=peek($880B) bxor $FF
'  chacknpopputchar(8,25,48+(ej0 mod 10))
'  chacknpopputchar(7,25,48+((int(ej0/10)) mod 10))
'  chacknpopputchar(6,25,48+((int(ej0/100)) mod 10))
'  chacknpopputchar(8,26,48+(ej1 mod 10))
'  chacknpopputchar(7,26,48+((int(ej1/10)) mod 10))
'  chacknpopputchar(6,26,48+((int(ej1/100)) mod 10))
'
'  for ee2=0 to 5
'    for ee3=0 to 7
'      chacknpopputsprite(ee3+(ee2*8),ex0+(ee3*16),ey0+(ee2*16),eee band 15,eee band 15)
'      next:next
'
'  ex0=ex0-((ej0 band 1)/1)+((ej0 band 2)/2)
'  ey0=ey0+((ej0 band 4)/4)-((ej0 band 8)/8)
'
'  eee=eee+1
'  for ee2=1 to 500:next
'  loop
'
'do:loop
'
'
