Author Topic: ZXScreen viewer  (Read 10809 times)

Offline Mikele

  • Mc. Print
  • *
  • Posts: 28
    • View Profile
ZXScreen viewer
« on: 2011-Oct-18 »
Hey,

This is my old Blitz3d code translated to GLBasic. I used it just to learn GLBasic. Additionally there's attached a compiled version with a few examples (press LMB or F9 to B&W/Color mode, RMB or F10 to "loadingstrips FX" ON/OFF and SPACE or F11 to load next ZX screen).

Code: (glbasic) [Select]
// --------------------------------- //
// Project: ZX Spectrum Screen
// Start: Monday, October 17, 2011
// IDE Version: 10.118


SETCURRENTDIR("Media") // go to media files

GLOBAL VIDRAM = 16384 //videoram
GLOBAL VIDATR = 22528 //attributes

GLOBAL ZXRAMbank[]
DIM ZXRAMbank[65536] //ZX memory image 16KB ROM + 48KB RAM

GLOBAL colortable[]
DIM colortable[16] //colors FOR WritePixelFast

MakeColors()

GLOBAL flashstate = TRUE
GLOBAL time = 250 // flash frq
GLOBAL oldTime
GLOBAL load = TRUE //loadingFX simulator
GLOBAL BWmode = FALSE
GLOBAL waitkey = 0


//------- demo --------

SETSCREEN 320,256,0

STARTDATA screens:
DATA "LuckyLucke.scr", "terrorpolis.scr", "ship.scr", "sen1.11.scr", "sen.scr", "knights.scr"
ENDDATA

GLOBAL scrCounter = 1, scrfile$
RESTORE screens
READ scrfile$
OpenSCR(scrfile$)

WHILE TRUE

ZXField()

IF waitkey > 0
waitkey = waitkey-1
ENDIF

MOUSESTATE mx, my, b1, b2


IF (KEY(67) = 1 OR b1 = 1) AND waitkey = 0 //KEY F9 = B/W / color mode

BWmode = NOT BWmode
waitkey = 10

IF BWmode = TRUE
MakeGrey()
ELSE
MakeColors()
ENDIF

ELSEIF (KEY(68) = 1 OR b2 = 1) AND waitkey = 0 //KEY F10 = border loading effect

load = 1 - load
waitkey = 10

ELSEIF (KEY(87) = 1 OR KEY(57) = 1) AND waitkey = 0 //KEY F10 = border loading effect

INC scrCounter
IF scrCounter > 6
scrCounter = 1
RESTORE screens
ENDIF

READ scrfile$
OpenSCR(scrfile$)
waitkey = 10

ENDIF

SHOWSCREEN
SLEEP 1

WEND

END

//---------------------


//.scr, .zx, .$c, .s  6912 AND 6929 are supported
FUNCTION OpenSCR: scrfile$, channel1=1
IF scrfile$<>"" AND (RIGHT$(scrfile$,4)=".scr" OR RIGHT$(scrfile$,3)=".zx" OR RIGHT$(scrfile$,2)=".s" OR RIGHT$(scrfile$,3)=".$c")
LOCAL sizefile=GETFILESIZE(scrfile$)

LOCAL screenfile = OPENFILE(channel1, scrfile$, 1)

IF sizefile = 6912
ReadBytes (channel1, 16384,6912)
ELSEIF sizefile = 6929
ReadBytes (channel1, 16384-17,6912)
ENDIF

CLOSEFILE 1
ENDIF
ENDFUNCTION

FUNCTION ReadBytes: chan, adres, lenght
LOCAL count, newDATA%
FOR count=0 TO lenght-1
READBYTE chan, newDATA%
ZXRAMbank[adres+count]=newDATA%
NEXT
ENDFUNCTION


//render ZX screen
FUNCTION ZXField:

LOCAL argb%

FlashEffect()

FOR y%=0 TO 255 STEP 2

IF load
argb = RND(10)
IF argb>5
IF BWmode=FALSE
argb = RGB(0,50,200)//blue strips
ELSE
argb = 5592405
ENDIF
ELSE
IF BWmode=FALSE
argb = RGB(200,200,40)//yellow strips
ELSE
argb = 0
ENDIF
ENDIF
ELSE
argb = 0
ENDIF

DRAWLINE 0,y, 320, y, argb
DRAWLINE 0,y+1, 320, y+1, argb

NEXT

DrawScreen(32, 32)

ENDFUNCTION

//get INK color
FUNCTION AttrInk: byte
RETURN bAND(byte,7)
ENDFUNCTION

//get PAPER color
FUNCTION AttrPaper: byte
RETURN bAND(ASR (byte,3),7)
ENDFUNCTION

//get BRIGHT attribute
FUNCTION AttrBright: byte
RETURN bAND(byte,64)
ENDFUNCTION

//get FLASH attribute
FUNCTION AttrFlash: byte
RETURN bAND(byte,128)
ENDFUNCTION

//video processor ;)
//x,y - screen coordinates (+32 pixels for border)
FUNCTION DrawScreen: X=32, Y=32
LOCAL Xpixel, Ypixel, bblok, bajt, attr, brightcolor, inkcolor, paperColor, flashcolor, temp, video, blok, at, bat, b, l
 
  Ypixel = Y
 
  FOR blok = 0 TO 2

bblok = blok * 256

FOR at = 0 TO 7

bat = at*32

  FOR l = 0+at*32+blok*2048 TO 2047+blok*2048 STEP 256

Xpixel = X

FOR b = 0 TO 31

bajt = ZXRAMbank[VIDRAM+b+l]
attr = ZXRAMbank[VIDATR+b+bat+bblok]
brightcolor = ASR (AttrBright (attr), 3)
// inkcolor = 7
// paperColor = 0
inkcolor = AttrInk (attr) + brightcolor
paperColor = AttrPaper (attr) + brightcolor

flashcolor = AttrFlash (attr)

IF flashcolor=128 AND flashstate = TRUE

temp=inkcolor
inkcolor=paperColor
paperColor=temp

ENDIF


video = bAND(bajt,128) //;1
SELECT video
CASE 128
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,64) //;2
SELECT video
CASE 64
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,32) //;3
SELECT video
CASE 32
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,16) //;4
SELECT video
CASE 16
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,8) //;5
SELECT video
CASE 8
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,4) //;6
SELECT video
CASE 4
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,2) //;7
SELECT video
CASE 2
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,1) //;8
SELECT video
CASE 1
SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
CASE 0
SETPIXEL Xpixel,Ypixel, colortable[paperColor]
ENDSELECT
Xpixel = Xpixel + 1
NEXT

     Ypixel = Ypixel + 1

NEXT

   NEXT

  NEXT

ENDFUNCTION

//FLASH timing
FUNCTION FlashEffect:
IF GETTIMERALL() > oldTime + time

IF flashstate = TRUE
flashstate = FALSE
oldTime=GETTIMERALL()
ELSE
flashstate = TRUE
oldTime=GETTIMERALL()
ENDIF
ENDIF
ENDFUNCTION

//ZXGreyscale
FUNCTION MakeGrey:
FOR k=0 TO 15
colortable[k] = Grey(colortable[k])
NEXT
ENDFUNCTION

//ZXSpectrum colors
FUNCTION MakeColors:
colortable[0] = RGB(0,0,0) //;BLACK
colortable[1] = RGB(0,10,120) //;BLUE
colortable[2] = RGB(200,20,20) //;RED
colortable[3] = RGB(200,40,200) //;MAGENTA
colortable[4] = RGB(20,200,20) //;GREEN
colortable[5] = RGB(40,200,200) //;CYAN
colortable[6] = RGB(200,200,40) //;YELLOW
colortable[7] = RGB(200,200,200) //;WHITE
colortable[8] = RGB(1,1,1) //;BLACK + BRIGHT
colortable[9] = RGB(0,20,200) //;BLUE + BRIGHT
colortable[10] = RGB(255,40,40) //;RED + BRIGHT
colortable[11] = RGB(255,80,255) //;MAGENTA + BRIGHT
colortable[12] = RGB(40,255,40) //;GREEN + BRIGHT
colortable[13] = RGB(80,255,255) //;CYAN + BRIGHT
colortable[14] = RGB(255,255,80) //;YELLOW + BRIGHT
colortable[15] = RGB(255,255,255) //;WHITE + BRIGHT
ENDFUNCTION

FUNCTION Grey: rgb1
red1=bAND(ASR(rgb1,16), 255)
green1=bAND(ASR(rgb1,8),255)
blue1=bAND(rgb1,255)

//simple grayscale
gray=(red1+green1+blue1)/3

//greyscale by Peter Scheutz
//gray=red1*0.3 + green1*.059 + blue1*0.11

red1=gray
green1=gray
blue1=gray
RETURN RGB(red1, green1, blue1)
ENDFUNCTION




Regards,

Michal

[attachment deleted by admin]

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 1020
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
Re: ZXScreen viewer
« Reply #1 on: 2011-Oct-19 »
Very cool !!!!!!!!!!!!!!!!

AND LOADING FX TOO!!!!

 ;)  8)

[attachment deleted by admin]
« Last Edit: 2011-Oct-19 by Hark0 »
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Offline caffeinekid

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
    • TCKSOFT
Re: ZXScreen viewer
« Reply #2 on: 2011-Oct-19 »
Very cool. I still love the ZX Spectrum and have mine safe in a box to preserve for future generations. :D

Offline Mikele

  • Mc. Print
  • *
  • Posts: 28
    • View Profile
Re: ZXScreen viewer
« Reply #3 on: 2011-Oct-19 »
Those were happy days with ZX Spectrum ;).

I'm still learning GLBasic. It's really awesome basic dialect.
This is modified version of DrawScreen function. Now it uses MEM2SPRITE technique and it's much faster than previous version. Now it works at decent speed on my Galaxy S.

Code: (glbasic) [Select]

FUNCTION DrawScreen: X=32, Y=32
LOCAL Xpixel, Ypixel, bblok, bajt, attr, brightcolor, inkcolor, paperColor, flashcolor, temp, video, blok, at, bat, b, l
DIM pix%[256*256]
  Ypixel = Y-32

  FOR blok = 0 TO 2

bblok = blok * 256

FOR at = 0 TO 7

bat = at*32

  FOR l = 0+at*32+blok*2048 TO 2047+blok*2048 STEP 256

Xpixel = X-32

FOR b = 0 TO 31

bajt = ZXRAMbank[VIDRAM+b+l]
attr = ZXRAMbank[VIDATR+b+bat+bblok]
brightcolor = ASR (AttrBright (attr), 3)
// inkcolor = 7
// paperColor = 0
inkcolor = AttrInk (attr) + brightcolor
paperColor = AttrPaper (attr) + brightcolor

flashcolor = AttrFlash (attr)

IF flashcolor=128 AND flashstate = TRUE

temp=inkcolor
inkcolor=paperColor
paperColor=temp

ENDIF


video = bAND(bajt,128) //;1
SELECT video
CASE 128
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,64) //;2
SELECT video
CASE 64
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,32) //;3
SELECT video
CASE 32
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,16) //;4
SELECT video
CASE 16
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,8) //;5
SELECT video
CASE 8
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,4) //;6
SELECT video
CASE 4
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,2) //;7
SELECT video
CASE 2
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,1) //;8
SELECT video
CASE 1
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1
NEXT

     Ypixel = Ypixel + 1

NEXT

   NEXT

  NEXT


MEM2SPRITE(pix[], 1, 256, 256)
DRAWSPRITE 1, 32, 32

ENDFUNCTION


Regards,

Michal

Offline caffeinekid

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
    • TCKSOFT
Re: ZXScreen viewer
« Reply #4 on: 2011-Oct-19 »
A Spectrum style framework would be cool - if that is a logical next step...

Commands to draw UDGs and text with attributes etc.

It's a shame there is no pitch commands for sound in GLBasic so it would make it hard or impossible to make a BEEP command. :)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: ZXScreen viewer
« Reply #5 on: 2011-Oct-19 »
There was a routine posted a few months ago that does just that Caff; IIRC it was called BEEP too.

BTW Nice routine Mikele :)
I came. I saw. I played.

Offline Hark0

  • Prof. Inline
  • *****
  • Posts: 1020
  • Geek Developer
    • View Profile
    • LitioPixel - Desarrollo de videojuegos con GLBasic | Videogame development with GLBasic
Re: ZXScreen viewer
« Reply #6 on: 2011-Oct-20 »
Those were happy days with ZX Spectrum ;).

I'm still learning GLBasic. It's really awesome basic dialect.
This is modified version of DrawScreen function. Now it uses MEM2SPRITE technique and it's much faster than previous version. Now it works at decent speed on my Galaxy S.

Code: (glbasic) [Select]

FUNCTION DrawScreen: X=32, Y=32
LOCAL Xpixel, Ypixel, bblok, bajt, attr, brightcolor, inkcolor, paperColor, flashcolor, temp, video, blok, at, bat, b, l
DIM pix%[256*256]
  Ypixel = Y-32

  FOR blok = 0 TO 2

bblok = blok * 256

FOR at = 0 TO 7

bat = at*32

  FOR l = 0+at*32+blok*2048 TO 2047+blok*2048 STEP 256

Xpixel = X-32

FOR b = 0 TO 31

bajt = ZXRAMbank[VIDRAM+b+l]
attr = ZXRAMbank[VIDATR+b+bat+bblok]
brightcolor = ASR (AttrBright (attr), 3)
// inkcolor = 7
// paperColor = 0
inkcolor = AttrInk (attr) + brightcolor
paperColor = AttrPaper (attr) + brightcolor

flashcolor = AttrFlash (attr)

IF flashcolor=128 AND flashstate = TRUE

temp=inkcolor
inkcolor=paperColor
paperColor=temp

ENDIF


video = bAND(bajt,128) //;1
SELECT video
CASE 128
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,64) //;2
SELECT video
CASE 64
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,32) //;3
SELECT video
CASE 32
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,16) //;4
SELECT video
CASE 16
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,8) //;5
SELECT video
CASE 8
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,4) //;6
SELECT video
CASE 4
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,2) //;7
SELECT video
CASE 2
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1

video = bAND(bajt,1) //;8
SELECT video
CASE 1
//SETPIXEL Xpixel,Ypixel, colortable[inkcolor]
pix[Xpixel + Ypixel*256] = bOR(colortable[inkcolor], ASL(0x00ffffff,24))//colortable[inkcolor]+ 0xff000000
CASE 0
//SETPIXEL Xpixel,Ypixel, colortable[paperColor]
pix[Xpixel + Ypixel*256] = bOR(colortable[paperColor], ASL(0x00ffffff, 24))//colortable[paperColor]+ 0xff000000
ENDSELECT
Xpixel = Xpixel + 1
NEXT

     Ypixel = Ypixel + 1

NEXT

   NEXT

  NEXT


MEM2SPRITE(pix[], 1, 256, 256)
DRAWSPRITE 1, 32, 32

ENDFUNCTION


Regards,

Michal

Make a full ZX emulator with GLB...  ;)
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10739
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: ZXScreen viewer
« Reply #7 on: 2011-Oct-20 »
see the SFXR example. It just creates a wav file on the fly and loads that. Not really great, but it works.

I have plans for a better sound engine that allows generation of synthetic sounds. But it's at the bottom of the todo.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2668
    • View Profile
Re: ZXScreen viewer
« Reply #8 on: 2011-Oct-20 »
I would imagine that the tone on the spectrum is just 256 separate pitches, maybe use SFXR to create these and load them into an array?
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Mikele

  • Mc. Print
  • *
  • Posts: 28
    • View Profile
Re: ZXScreen viewer
« Reply #9 on: 2011-Oct-21 »
Make a full ZX emulator with GLB...  ;)

Hehe. Honestly I wrote partially working Z80 processor simulator years ago (I should have blitz source somewhere). But it could be difficult to merge all these things together - I'm just a weekend programmer ;).

see the SFXR example. It just creates a wav file on the fly and loads that. Not really great, but it works.

I'll take a look at that. I'd like to code an AY player ;).
« Last Edit: 2011-Oct-21 by Mikele »

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
Re: ZXScreen viewer
« Reply #10 on: 2011-Oct-25 »
I did have a look about for a z80 core written in basic and noticed that there was a full spectrum emulator written in basic a while back but no source code available and then thought about sound and quickly forgot about even thinking about that project :(

But a nice bit of code there

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: ZXScreen viewer
« Reply #11 on: 2011-Oct-25 »
Cool  =D

I done a similar program in blitz which loaded the screens from SNA & Z80 snapshots. It loaded the screens in the same way as the spectrum so you see them being generated like a real speccy, first the pixels followed by the colour. Never thought about doing the loading border though so hats off for that  :enc:
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline AMateus

  • Mr. Drawsprite
  • **
  • Posts: 61
    • View Profile
Re: ZXScreen viewer
« Reply #12 on: 2011-Oct-26 »

Offline Nathan

  • Mr. Polyvector
  • ***
  • Posts: 116
    • View Profile
Re: ZXScreen viewer
« Reply #13 on: 2011-Oct-26 »
A ZX Spectrum emulator in VB, class!  Also crazy.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: ZXScreen viewer
« Reply #14 on: 2011-Oct-26 »
Ah man if only I was in Uni again and had all the time in the world (assuming you ignore lectures like I did) to convert it to GLB. Unfortuantly you have to worry about the legality of including the ROMs (eg. +2 ROM).

Even if there is a way round the machine ROMs you have the problem of the game ROMs. You could of course use freeware Spectrum games rather than proper game roms (dodgy ground) and there is a similar list of Spectrum games (expensive!) on the iOS app store, but that much effort with potentially an un-sellable product equals me wishing I was in Uni again :)

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.