Close

Compiled test example MAPGEN for multiple platforms

A project log for nedoPC SDK

Software Development Kit for DIY programmable devices, Retro computers and Supercon badges ;)

shaosSHAOS 07/16/2024 at 06:490 Comments

Major reincarnation milestone has passed - I was able to compile old test project for all supported platforms (at this moment) - program PRJ/MAPGEN/MAIN.R written in Robby programming language:

robot "MapGen"
author "Shaos"

+INC/ROBBY
+TILES

@DMBOX=10
@DX=20
@DY=10
@SIZE=200

main()
{
 DEF map[@SIZE]
 buff = 0
 SetRand(14)
 _M_reactor = 0x2
 _M_hole    = 2
 _M_box     = 5
 _M_rock    = 20
 DEF _X_box[@DMBOX]
 DEF _Y_box[@DMBOX]
 _N_box = 0;
 dx = 0
 dy = 0

 command @P2_TERMINFO
 dx=A;dy=B
 x0=(dx-20)/2
 y0=(dy-12)/2
 A=x0;B=y0;C=2
 command @P2_SETSAY
 say "  ROBOT WARFARE  1  "
 A=x0;B=y0+11;C=1
 command @P2_SETSAY
 SayRand(0)

again:

 SayRand(1)
 MakeMap(2,@DX,@DY)

 kk = 0
 for(jj=1,jj<=@DY,jj++)
 {
   for(ii=0,ii<@DX,ii++)
   {
       c = map[kk]>>4;
       kk = kk+1
       select(x0+ii,y0+jj)
       if(c==0) set @sp_e
       if(c==1) set @sp_h
       if(c==2) set @sp_s
       if(c==3) set @sp_b
       if(c==4) set @sp_r
       if(c==6) set @sp_r0
   }
 }

 while(1)
 {
    recv buff
    if(buff) break
 }

 goto again
}


+LIB/RANDOM

SayRand()
{
  say "MAPGEN #&RAND        "
}

// A-N, B-X, C-Y
MakeMap()
{
   num = A
   dx = B
   dy = C
   sz = dx*dy
   reactor = num * _M_reactor
   hole    = num * _M_hole
   box     = num * _M_box
   rock    = num * _M_rock
   for(A=0,A<sz,A++)
   {
      map[A] = 0
   }
   C = 0
   for(B=0,B<rock,B++)
   {
      while(map[C])
      {
         Random(sz)
      }
      map[C] = 0x25
   }
   for(B=0,B<hole,B++)
   {
      while(map[C])
      {
         Random(sz)
      }
      map[C] = 0x10
   }
   for(B=0,B<box,B++)
   {
      while(map[C])
      {
         Random(sz)
      }
      map[C] = 0x30
      if(_N_box<@DMBOX)
      {
         _X_box[_N_box]=B%dx
         _Y_box[_N_box]=B/dx
         _N_box = _N_box+1
      }
   }
   for(B=0,B<reactor,B++)
   {
      while(map[C])
      {
         Random(sz)
      }
      map[C] = 0x40
   }
   for(B=0,B<num,B++)
   {
      while(map[C])
      {
         Random(sz)
      }
      map[C] = 0x60 + B
   }
}

 Old library LIB/RANDOM.R:

SetRand() // A-RAND
{
  Rand = A
}

Random() // A-RANGE => C-RESULT L=C
{
  Rand = 0x6255*Rand+0x3619
  C = ((Rand&0xFF00)|(((Rand>>8)^Rand)&0x00FF))&0x7FFF
  if(A) C=C%A; 
  return C
}

 Original tiles defined in text file PRJ/MAPGEN/TILES.SPR:

;8x8-2/16

SP_E    DB  #55,#AA,#55,#AA,#55,#AA,#55,#AA,#F0 ;.!
SP_H    DB  #55,#BE,#7F,#FE,#7F,#FE,#7D,#AA,#F0 ;O!
SP_S    DB  #00,#2A,#54,#2A,#54,#2A,#54,#00,#07 ;@
SP_B    DB  #00,#54,#7E,#54,#54,#7E,#54,#00,#30 ;#!
SP_R    DB  #00,#76,#6E,#42,#7A,#56,#4E,#00,#CE ;*
SP_F    DB  #55,#AA,#5D,#BE,#5D,#AA,#55,#AA,#CE ;+
SP_R0   DB  #18,#7E,#7E,#3C,#3C,#7E,#7E,#00,#40 ;R!
SP_0    DB  #00,#00,#00,#00,#00,#00,#00,#00,#00 ;
SP_1    DB  #00,#00,#00,#00,#00,#00,#00,#00,#11 ;.!

Z80 target estex (computer PetersPlus Sprinter from 2002 with Estex operating system):

Z80 target trdos (computer ZX Spectrum with beta-disk interface and TR-DOS operating system):

i8080 target speccy (the same computer ZX Spectrum in original 48k form from 1982, but code was compiled through i8080 assembler and this build uses original ZX Spectrum font):

i8080 target orion (soviet computer Orion-128/256 from 1990 with ORDOS operating system):

i8080 target spetsmx (soviet computer Spetsialist-MX from 1991 that had 16-color graphics):

i8080 target spets (soviet computer Spetsialist from 1987 in original monochrome form):

i8080 target radio (soviet computer Radio-86RK from 1986 that had text mode only):

This target is default one - nedomake will build it if no target is specified - it should be easy enough to create a text suit on it running on GitLab CI/CD after every push to make sure everything is correct...

Discussions