Okay, I'm stuck. I'm trying to create a ASCII emulator; the reason is that OSX doesn't have support for ASCII and I want to convert some of my old ASCII Turbo Pascal games over to BM.
I'm taking a text file that has the pixel data and plotting it out on the pixmap. I then grab a 8x8 image and put it into an array, which I can use to print a character to the screen.
That works fine. But now I want to have code that can change the color of the text. NOT text that's already shown to the user, but go back and change the text color (foreground and background) for all future printed text. And that's where I'm stuck.
Any help?
P.S., one of the main reasons that I'm using a text file to store the data is I also plan on re-using this to create character sets that look like Atari and Commodore character sets for other conversion projects.
You'll need this text file for testing:
Click here!
I'm taking a text file that has the pixel data and plotting it out on the pixmap. I then grab a 8x8 image and put it into an array, which I can use to print a character to the screen.
That works fine. But now I want to have code that can change the color of the text. NOT text that's already shown to the user, but go back and change the text color (foreground and background) for all future printed text. And that's where I'm stuck.
Any help?
P.S., one of the main reasons that I'm using a text file to store the data is I also plan on re-using this to create character sets that look like Atari and Commodore character sets for other conversion projects.
You'll need this text file for testing:
Click here!
' IBM ASCII Simulator SetGraphicsDriver GLMax2DDriver() Global GrabLine:String="" Global Lop :Int=0 ' Generic looping variable. Re-useable. Global Lop1 :Int=0 ' Generic looping variable. Re-useable. Global AscNum:Int=-1 Global AscRow:Int=0 Global AscCol :Int=-1 Global xPos :Int=-1 Global MoveToNextChar :Int=0 Global Char_Array[256] ' Stores graphics in an array that corresponds to ASCII codes Global r1,g1,b1 :Int=1 Global r2,g2,b2 :Int=1 Global bgcolor :Int=1 ' background color of text Global fgcolor :Int=1 ' foreground color of text Graphics 640,480,0,60 Load_N_Plot(4,5) ' Syntax: Load_N_Plot(foreground color[range 0-16], background color[range 0-16]) Snag Cls put_xy(072,100,100) put_xy(105,108,100) put_xy(105,116,100) WaitKey put_xy(105,128,100) WaitKey End Function Load_N_Plot(fgcolor,bgcolor) file=OpenFile("IBM_ASCII.txt") If Not file Print "Could not load" Else While Not Eof(file) xPos=-1 AscNum=AscNum+1 GrabLine = ReadLine(file) ConvertFromLineToGFX(GrabLine,fgcolor,bgcolor) Wend CloseStream file End If End Function ' function put_xy SYNTAX: put_xy(character, x, y) ' - character : ascii code for the character you wish to plot ' - x : draw character at x-coord ' - y : draw character at y-coord ' Function put_xy(cc:Int, xx:Int, yy:Int) DrawPixmap(Char_Array[cc], xx, yy) Flip End Function ' function Snag - converts the plotted image into individual array elements. Function Snag() Local xx=0 Local yy=0 For lop=0 To 255 Select lop Case 64 ;xx=0 ;yy=10 Case 128 ;xx=0 ;yy=20 Case 192 ;xx=0 ;yy=30 End Select Char_Array[lop]=GrabPixmap(xx, yy, 10, 10) xx=xx+10 Next End Function Function WipeCharArray() For lop=0 To 255 Char_Array[lop]=Null Next End Function Function ConvertFromLineToGFX(GrabLine$,fgcolor,bgcolor) Local IncLine=0 AscCol=AscCol+1 For Lop=0 To 63 'length of charset data (8x8=64) Local temp$=GrabLine[Lop..Lop+1] xPos=xPos+1 Select fgcolor Case 0 ;r1=000 ;g1=000 ;b1=000 Case 1 ;r1=000 ;g1=000 ;b1=170 Case 2 ;r1=000 ;g1=170 ;b1=000 Case 3 ;r1=000 ;g1=170 ;b1=170 Case 4 ;r1=170 ;g1=000 ;b1=000 Case 5 ;r1=170 ;g1=000 ;b1=170 Case 6 ;r1=170 ;g1=085 ;b1=000 Case 7 ;r1=170 ;g1=170 ;b1=170 Case 8 ;r1=170 ;g1=170 ;b1=170 Case 9 ;r1=170 ;g1=170 ;b1=255 Case 10 ;r1=170 ;g1=255 ;b1=170 Case 11 ;r1=170 ;g1=255 ;b1=255 Case 12 ;r1=255 ;g1=170 ;b1=170 Case 13 ;r1=255 ;g1=170 ;b1=255 Case 14 ;r1=255 ;g1=255 ;b1=170 Case 15 ;r1=255 ;g1=255 ;b1=255 End Select Select bgcolor Case 0 ;r2=000 ;g2=000 ;b2=000 Case 1 ;r2=000 ;g2=000 ;b2=170 Case 2 ;r2=000 ;g2=170 ;b2=000 Case 3 ;r2=000 ;g2=170 ;b2=170 Case 4 ;r2=170 ;g2=000 ;b2=000 Case 5 ;r2=170 ;g2=000 ;b2=170 Case 6 ;r2=170 ;g2=085 ;b2=000 Case 7 ;r2=170 ;g2=170 ;b2=170 Case 8 ;r2=170 ;g2=170 ;b2=170 Case 9 ;r2=170 ;g2=170 ;b2=255 Case 10 ;r2=170 ;g2=255 ;b2=170 Case 11 ;r2=170 ;g2=255 ;b2=255 Case 12 ;r2=255 ;g2=170 ;b2=170 Case 13 ;r2=255 ;g2=170 ;b2=255 Case 14 ;r2=255 ;g2=255 ;b2=170 Case 15 ;r2=255 ;g2=255 ;b2=255 End Select If temp$="." Then SetColor r2,b2,g2 If temp$="X" Then SetColor r1,b1,g1 Select Lop ' This part plots each line from data into each image character Case 8 ;IncLine=1 ;xPos=0 Case 16 ;IncLine=2 ;xPos=0 Case 24 ;IncLine=3 ;xPos=0 Case 32 ;IncLine=4 ;xPos=0 Case 40 ;IncLine=5 ;xPos=0 Case 48 ;IncLine=6 ;xPos=0 Case 56 ;IncLine=7 ;xPos=0 Case 64 ;IncLine=8 ;xPos=0 End Select Select AscNum 'Positioning on Window Case 64 ;AscRow=10 ;AscCol=0 Case 128 ;AscRow=20 ;AscCol=0 Case 192 ;AscRow=30 ;AscCol=0 End Select Plot xPos+(AscCol)*10,IncLine+AscRow Next End Function
