asm
  ld sp,$6FFF
  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 mariobrosputchar(txpos as uinteger,typos as uinteger,tchr as ubyte):
  poke $7400+txpos+(typos*32),tchr
  end sub

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

for ee0=0 to 15
  for ee1=0 to 15
    seed=smsrnd(seed)
    mariobrosputchar(ee1+15,ee0+13,ee0*16+ee1)
    smsdelay(1000)
    next:next

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

mariobrosputchar(1,3,48+(int(eee/10000) mod 10))
mariobrosputchar(2,3,48+(int(eee/1000) mod 10))
mariobrosputchar(3,3,48+(int(eee/100) mod 10))
mariobrosputchar(4,3,48+(int(eee/10) mod 10))
mariobrosputchar(5,3,48+(eee mod 10))

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

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

ex0=ex0+((ee0 band 1)/1)-((ee0 band 2)/2)
ey0=ey0+((ee1 band 1)/1)-((ee1 band 2)/2)

mariobrosputchar(ex0,ey0,32+(eee mod 64))

eee=eee+1
loop

do:loop

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

loop

do

for eee=$7400 to $7FFF
  seed=smsrnd(seed)
  poke eee,seed
  for ee2=0 to 1000:next
  next
for eee=$7000 to $73FF
  seed=smsrnd(seed)
  poke eee,seed
  for ee2=0 to 1000:next
  next

loop


'static ADDRESS_MAP_START( mario_map, AS_PROGRAM, 8, mario_state)
'AM_RANGE(0x0000, 0x5fff) AM_ROM
'AM_RANGE(0x6000, 0x6fff) AM_RAM
'AM_RANGE(0x7000, 0x73ff) AM_RAM AM_SHARE("spriteram") /* physical sprite ram */
'AM_RANGE(0x7400, 0x77ff) AM_RAM_WRITE(mario_videoram_w) AM_SHARE("videoram")
'AM_RANGE(0x7c00, 0x7c00) AM_READ_PORT("IN0") AM_WRITE(mario_sh1_w) /* Mario run sample */
'AM_RANGE(0x7c80, 0x7c80) AM_READ_PORT("IN1") AM_WRITE(mario_sh2_w) /* Luigi run sample */
'AM_RANGE(0x7d00, 0x7d00) AM_WRITE(mario_scroll_w)
'AM_RANGE(0x7e80, 0x7e80) AM_WRITE(mario_gfxbank_w)
'AM_RANGE(0x7e82, 0x7e82) AM_WRITE(mario_flip_w)
'AM_RANGE(0x7e83, 0x7e83) AM_WRITE(mario_palettebank_w)
'AM_RANGE(0x7e84, 0x7e84) AM_WRITE(nmi_mask_w)
'AM_RANGE(0x7e85, 0x7e85) AM_WRITE(mario_z80dma_rdy_w)   /* ==> DMA Chip */
'AM_RANGE(0x7f00, 0x7f07) AM_WRITE(mario_sh3_w) /* Sound port */
'AM_RANGE(0x7f80, 0x7f80) AM_READ_PORT("DSW")    /* DSW */
'AM_RANGE(0x7e00, 0x7e00) AM_WRITE(mario_sh_tuneselect_w)
'AM_RANGE(0xf000, 0xffff) AM_ROM
'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
'
'
