Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
10-26-2022, 03:17 PM
(This post was last modified: 10-26-2022, 03:20 PM by mnrvovrfc.
Edit Reason: Fixed grammar mistake
)
I created a sub that has too many parameters but could fake the block graphic characters drawn by ancient computers such as the TRS-80 Model III. I have found a bug while composing this on Linux.
Code: (Select All) option _explicit
dim as integer i, x, y, re, be, ge, scw, sch, saiz
scw = 1152
sch = 672
screen _newimage(scw, sch, 32)
saiz = 48
re = 96
ge = re
be = re
'for i = 128 to 191
' block i - 128, saiz, 2, 3, x, y, _rgb(255, 255, 255)
' x = x + saiz
' if x >= 800 then
' x = 0
' y = y + saiz
' end if
'next
'goto pend
saiz = 12
for i = 0 to 4095
block i, saiz, 3, 4, x, y, _rgb(re, ge, be)
x = x + saiz
if x >= scw then
x = 0
y = y + saiz
if y >= sch then exit for
ge = ge + 32
if ge > 255 then ge = 96: be = be + 12
end if
next
pend:
sleep
system
''num = fake character code (bits will be checked)
''siz = point size of the whole "rectangle"
''wd = number of pixels across
''ht = number of pixels vertically
''xx, yy = coordinates of top-left corner (desired to avoid this and "co")
''co = 32-bit color value
''eg. TRS-80 monochrome graphics, wd = 2 and ht = 3, graphics 128 x 48
''for Tandy Coco as well "num" must start at zero but graphics chars started at CHR$(128)
sub block (num as _unsigned integer, siz as integer, wd as integer, ht as integer, xx as single, yy as single, co as long)
static as integer x, y, k
static as _byte p
static as long m
static as single w, h
w = siz / wd
h = siz / ht
p = 0
for y = 0 to ht - 1
for x = 0 to wd - 1
m = 2 ^ p
if num and m then
line(xx + x * w, yy + y * h)-step(w, h), co, bf
end if
p = p + 1
next
next
end sub
The colors are a vain attempt to see the influence of the pixel rows more clearly. This should have range checking. This wasn't tested under "VIEW" and "WINDOW" setting.
Composed this on Fedora 36 MATE. (Yeah got stuck yesterday waiting for 37 to discover they postponed it for another week!)
This is the bug:
On a laptop or other screen with 768 pixels vertically, try changing "sch" to a value higher than 672, compile and run. The top part of the picture is scrolled off as if "PRINT" were used without semicolon near the bottom of the screen. This is seen more obviously if the commented parts were the demonstration, which draws much-larger pixel blocks. This drove me crazy for about half an hour and while I was getting the 3x4-pixel thing straightened out.
My laptop has only 768 pixels vertically. With "task bar" enabled the area is reduced to 720 or less, however that "task bar" has no influence on the user program's window. Maybe somebody with a larger viewport hardware could handle a larger size, but this bug should happen when the vertical dimension is quite near the maximum.
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
Code: (Select All) ''num = fake character code (bits will be checked)
''siz = point size of the whole "rectangle"
''wd = number of pixels across
''ht = number of pixels vertically
''xx, yy = coordinates of top-left corner (desired to avoid this and "co")
''co = 32-bit color value
''eg. TRS-80 monochrome graphics, wd = 2 and ht = 3, graphics 128 x 48
''for Tandy Coco as well "num" must start at zero but graphics chars started at CHR$(128)
sub block (num as _unsigned integer, siz as integer, wd as integer, ht as integer, xx as single, yy as single, co as long)
static as integer x, y, k
static as _byte p
static as long m
static as single w, h
w = siz / wd
h = siz / ht
p = 0
for y = 0 to ht - 1
for x = 0 to wd - 1
m = 2 ^ p
if num and m then
line(xx + x * w, yy + y * h)-step(w, h), co, bf
end if
p = p + 1
next
next
end sub
Don't understand the use of STATIC in this sub. Static should be used to preserve values between calls to the Sub.
Here every single variable is reassigned by the code, nothing is reused between calls ie a normal Dim (or ReDim) would be fine for declaring these variables for Option _Explicit.
I know this doesn't effect the functioning of the sub but it is a tiny bit less efficient to preserve values of variables between calls to a sub ie it uses more memory.
Just curious if you knew?
b = b + ...
Posts: 545
Threads: 116
Joined: Apr 2022
Reputation:
39
I like old-school graphics. A lot more creative work is required to make a block of 20 pixels look like and alien invader (for example).
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
(10-26-2022, 04:24 PM)bplus Wrote: Don't understand the use of STATIC in this sub. Static should be used to preserve values between calls to the Sub. I have disliked using "DIM" if not for arrays, so I would use an alternative to declare variables if it exists, because I also dislike making an entire subprogram "STATIC". This is related to "_DEFINE A-Z AS LONG" on top of the program or not making any difference in program performance on 64-bit. I used to write that statement before I got ahold of "OPTION _EXPLICIT". I'm going to hang on to integers most of the time although you and @Pete were only two people convincing me that it doesn't matter a lot at this point what is the "default" numeric variable.
Remember I also program in Lua, in that one directly from the developers must use "local" inside a function to protect variables that are to be used only inside that function, otherwise they are global. I gave that link because there are variations of Lua floating around (such as RENOISE scripting device) that compel an "OPTION _EXPLICIT" mode and have more OOP features.
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
10-26-2022, 07:20 PM
(This post was last modified: 10-27-2022, 06:18 PM by mnrvovrfc.
Edit Reason: Had written "&HB" instead of "&B" which is incorrect for binary notation.
)
(10-26-2022, 04:47 PM)James D Jarvis Wrote: I like old-school graphics. A lot more creative work is required to make a block of 20 pixels look like and alien invader (for example). Also I would have to change "num" type to "LONG". Otherwise it's just "&B" logic which is reversed. The "units" place always controls the pixel in the top-left corner. Just draw it on 5x4 grid with zeroes and ones, put it in a single line, reverse it and put "&B" in front of it and use it as parameter to "VAL()" function.
I say again, as it stands it would accept only blocks of up to 16 pixels within because the first parameter to "block" sub is 16-bit integer and not 32-bit.
EDIT: Sorry about confusing people here! It's "&B" not "&HB", for the latter was actually creating a hexadecimal number! Tripped upon this while creating the example program below. Again I ask apologies for the confusion this might have caused.
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
Should have appeared in the screenie of a real TRS-80 Model III, huh?
Code: (Select All) option _explicit
dim as integer i, x, y, scw, sch, saiz
dim v as _unsigned integer
dim a$
scw = 1152
sch = 672
screen _newimage(scw, sch, 32)
saiz = 20
x = 0
y = 0
i = 0
read a$
do until a$ = "END"
v = val(a$)
block v, saiz, 2, 3, x, y, _rgb(128, 128, 128)
x = x + saiz
i = i + 1
if i > 63 then
i = 0
x = 0
y = y + saiz
end if
read a$
loop
sleep
system
''num = fake character code (bits will be checked)
''siz = point size of the whole "rectangle"
''wd = number of pixels across
''ht = number of pixels vertically
''xx, yy = coordinates of top-left corner (desired to avoid this and "co")
''co = 32-bit color value
''eg. TRS-80 monochrome graphics, wd = 2 and ht = 3, graphics 128 x 48
''for Tandy Coco as well "num" must start at zero but graphics chars started at CHR$(128)
sub block (num as _unsigned integer, siz as integer, wd as integer, ht as integer, xx as single, yy as single, co as long)
static as integer x, y, k
static as _byte p
static as long m
static as single w, h
w = siz / wd
h = siz / ht
p = 0
for y = 0 to ht - 1
for x = 0 to wd - 1
m = 2 ^ p
if num and m then
line(xx + x * w, yy + y * h)-step(w, h), co, bf
end if
p = p + 1
next
next
end sub
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B110000,&B110000,&B110000
DATA &B110000,&B010000,&B000000,&B001011,&B111100,&B110100,&B000000
DATA &B101010,&B010000,&B011010,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B010101,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B111000,&B111110,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111100,&B111110,&B111111
DATA &B111101,&B110010,&B111101,&B010000,&B001011,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B010000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B101010,&B100001,&B111111,&B000101,&B010000
DATA &B101011,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B010000,&B000010
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111101,&B010000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B111110,&B101010,&B010101,&B000000
DATA &B000011,&B100010,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111101
DATA &B000000,&B000010,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111101,&B010000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B111111,&B000010,&B110101
DATA &B000000,&B000000,&B101010,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B010101,&B000000,&B001010,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B110100,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B111111,&B010100
DATA &B101011,&B110100,&B110011,&B111110,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B010100,&B010000,&B001011,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B010101,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B111111
DATA &B111101,&B111110,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B100010
DATA &B111111,&B111111,&B111111,&B111111,&B111101,&B110000,&B110000
DATA &B111011,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B011111
DATA &B000111,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B110100,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B001000,&B001100,&B101110
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B101111,&B111111,&B111111,&B010111
DATA &B101010,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B011111,&B000011
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B111111,&B110100,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B101010,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111110,&B111111,&B111111
DATA &B110111,&B101010,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B011111,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B111111,&B111111,&B110100,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B111010,&B111111,&B111111,&B000111,&B000001,&B001111
DATA &B101111,&B111111,&B111111,&B111111,&B110111,&B111000,&B111111
DATA &B111111,&B110101,&B111010,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B011111
DATA &B101111,&B111111,&B111111,&B111111,&B111111,&B011111,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B111111,&B111111,&B111111,&B111101
DATA &B010000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B101010,&B111111,&B000001,&B010100,&B000000
DATA &B000000,&B101010,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B000000,&B000000,&B000010,&B000011,&B000011,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111101,&B110000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000010,&B000111,&B001010,&B000101
DATA &B000000,&B000000,&B001110,&B001111,&B001111,&B001111,&B000011
DATA &B110011,&B111000,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B110101,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111100
DATA &B110000,&B010000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000010
DATA &B110011,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B010100,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111101,&B111100,&B111100
DATA &B111100,&B111100,&B111100,&B111100,&B111100,&B111110,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B010000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B110100,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111111,&B111111,&B111111
DATA &B111111,&B111111,&B111111,&B111111,&B111100,&B110000,&B110000
DATA &B110000,&B110000,&B110000,&B110000,&B110000,&B111100,&B111100
DATA &B010000,&B000000,&B000000,&B000000,&B000000,&B000000,&B000000
DATA &B000000,&B000000,END
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
10-27-2022, 06:34 PM
(This post was last modified: 10-27-2022, 06:41 PM by bplus.)
Well turn that sideways and it looks like something
Want to see my bats, being so close to Halloween and all? They come flying in lower right corner.
Code: (Select All) 'this is bats flying in swirl twister but takes awhile to become visible in lower right corner
Screen _NewImage(800, 600, 32)
_ScreenMove 300, 50
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0
Data 1,1,0,0,1,0,0,1,0,0,1,0,0,1,1,0
Data 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0
Data 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0
Data 0,0,0,0,1,0,1,1,1,0,0,1,0,0,0,0
Data 0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0
Data 0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0
Data 0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0
Data 0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Dim Shared sprt(15, 15)
For y = 0 To 15
For x = 0 To 15
Read sprt(x, y)
Next
Next
Dim Shared sprt2(15, 15)
For y = 0 To 15
For x = 0 To 15
Read sprt2(x, y)
Next
Next
Type btype
x As Single
y As Single
f As Integer
a As Single
End Type
Dim Shared bs(10000) As btype
bi = -1
While 1
Cls , _RGB32(0, 0, 128)
nloop = nloop + 1
If Rnd < .15 And (bi + 1) < 10000 Then
bi = bi + 1
newb bi
End If
For i = 0 To bi
drawb i
Next
_Display
_Limit 20
Wend
Sub newb (i)
bs(i).x = 800 + Rnd * 320
bs(i).y = 600 + Rnd * 80
bs(i).f = Int(Rnd * 2)
bs(i).a = 0
End Sub
Sub drawb (i)
If bs(i).a < _Pi(16) And bs(i).y < 580 And bs(i).y > -100 Then
bs(i).a = bs(i).a + _Pi(1 / 144)
bs(i).x = bs(i).x + bs(i).a * Cos(bs(i).a)
bs(i).y = bs(i).y + .2 * bs(i).a * Sin(bs(i).a)
bs(i).y = bs(i).y - .2
Else
bs(i).x = bs(i).x - (Rnd * 8 + 2)
bs(i).y = bs(i).y - (Rnd * 6 + 1)
End If
If bs(i).y < -160 Then newb i
bs(i).f = (bs(i).f + 1) Mod 10
sz = (600 - bs(i).y) * .006
If bs(i).f = 0 Or bs(i).f = 1 Then
For y = 0 To 15
For x = 0 To 15
If sprt2(x, y) Then Line (x * sz + bs(i).x, y * sz + bs(i).y)-Step(sz, sz), _RGB32(0, 0, 0), BF
Next
Next
Else
For y = 0 To 15
For x = 0 To 15
If sprt(x, y) Then Line (x * sz + bs(i).x, y * sz + bs(i).y)-Step(sz, sz), _RGB32(0, 0, 0), BF
Next
Next
End If
End Sub
b = b + ...
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
10-27-2022, 11:38 PM
Thank you math teacher, for as many as 10 thousand bats LOL.
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
11-01-2022, 11:07 PM
More jaggies, like the Radio Shack TRS-80 Color Computer 2, without extended BASIC!
Code: (Select All) ''by mnrvovrfc 2022-nov-01
option _explicit
dim shared as integer mnrvovrfc_coco_pw, mnrvovrfc_coco_ph
dim as integer z, u
randomize timer
screen _newimage(640, 480, 12)
cocosetdimauto
cls
for z = 0 to 511
printat z, 137 + 3 * (z > 255) + int(rnd * 8) * 16
next
_delay 3000
cls
for z = 0 to 511
read u
printat z, u
next
sleep
system
sub cocosetdim (pw as integer, ph as integer)
if pw < 1 or pw > 16 then exit sub
if ph < 1 or ph > 16 then exit sub
mnrvovrfc_coco_pw = pw
mnrvovrfc_coco_ph = ph
end sub
sub cocosetdimauto ()
dim as integer scrnw, scrnh
mnrvovrfc_coco_pw = _width / 64
mnrvovrfc_coco_ph = _height / 32
end sub
sub printat (cp as integer, ch as integer)
if cp < 0 or cp > 511 then exit sub
if ch < 128 or ch > 255 then exit sub
dim as integer co, cx, cy, xx, yy, scrnw, scrnh, i
scrnw = _width
scrnh = _height
cx = (cp mod 32) * mnrvovrfc_coco_pw * 2
cy = (cp \ 32) * mnrvovrfc_coco_ph * 2
select case ch
case is < 144
co = 2
case is < 160
co = 14
case is < 176
co = 1
case is < 192
co = 4
case is < 208
co = 7
case is < 224
co = 3
case is < 240
co = 5
case else
co = 12
end select
if cx + mnrvovrfc_coco_pw < scrnw or cy + mnrvovrfc_coco_ph < scrnh then
xx = cx
yy = cy
for i = 0 to 3
if i = 2 then
xx = cx
yy = yy + mnrvovrfc_coco_ph
end if
if ch and (2 ^ i) then
line(xx, yy)-step(mnrvovrfc_coco_pw, mnrvovrfc_coco_ph), co, bf
end if
xx = xx + mnrvovrfc_coco_pw
next
end if
end sub
'This is only for green-on-black. Add multiple of 16 up to 112 to start at 240 for orange.
'128
'__
'__
'129
'x_
'__
'130
'_x
'__
'131
'xx
'__
'132
'__
'x_
'133
'x_
'x_
'134
'_x
'x_
'135
'xx
'x_
'136
'__
'_x
'137
'x_
'_x
'138
'_x
'_x
'139
'xx
'_x
'140
'__
'xx
'141
'x_
'xx
'142
'_x
'xx
'143
'xx
'xx
DATA 128,128,128,128,128,128,128,158,159,159,159,159,159,159,159,159,159
DATA 159,159,159,159,159,159,157,128,128,128,128,128,128,128,128,128,128
DATA 128,128,128,128,158,159,159,159,159,159,159,159,159,159,159,159,159
DATA 159,159,159,159,159,157,128,128,128,128,128,128,128,128,128,128,128
DATA 128,158,159,159,159,159,159,159,159,159,159,159,159,159,159,159,159
DATA 159,159,159,159,157,128,128,128,128,128,128,128,128,128,128,159,159
DATA 159,159,159,159,159,159,159,159,159,159,159,159,159,159,159,159,159
DATA 159,159,159,159,128,128,128,128,128,128,128,128,128,159,159,159,147
DATA 147,147,147,147,147,147,147,147,147,147,147,147,147,147,147,147,159
DATA 159,159,128,128,128,128,128,128,128,128,128,159,159,147,128,128,200
DATA 204,204,196,128,128,128,128,128,200,204,204,196,128,128,147,159,159
DATA 128,128,128,128,128,128,128,133,128,159,147,128,128,128,202,128,128
DATA 197,128,128,128,128,128,202,128,128,197,128,128,128,147,159,128,138
DATA 128,128,128,128,128,133,128,159,128,128,128,128,202,196,200,197,128
DATA 128,128,128,128,202,196,200,197,128,128,128,128,159,128,138,128,128
DATA 128,128,128,141,143,159,128,128,128,128,128,197,128,128,128,184,188
DATA 180,128,128,128,202,128,128,128,128,128,159,143,142,128,128,128,128
DATA 128,139,143,159,128,128,128,128,128,197,128,128,128,186,191,181,128
DATA 128,128,202,128,128,128,128,128,159,143,135,128,128,128,128,128,128
DATA 143,143,250,255,255,128,128,197,128,128,128,178,179,177,128,128,128
DATA 202,128,128,255,255,245,143,143,128,128,128,128,128,128,128,138,143
DATA 250,255,255,128,128,197,128,220,220,220,220,220,220,220,128,202,128
DATA 128,255,255,245,143,133,128,128,128,128,128,128,128,128,139,242,243
DATA 243,128,128,128,128,219,223,223,223,223,223,215,128,128,128,128,243
DATA 243,241,135,128,128,128,128,128,128,128,128,128,128,227,227,227,227
DATA 227,239,236,236,211,211,211,211,211,236,236,239,227,227,227,227,227
DATA 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128
DATA 128,239,128,128,128,128,128,239,128,128,128,128,128,128,128,128,128
DATA 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,226
DATA 236,236,236,236,236,225,128,128,128,128,128,128,128,128,128,128,128
DATA 128,128
"printat" is used like this. Convert from old BASIC:
Code: (Select All) PRINT @255, CHR$(240)
to
Code: (Select All) printat 255, 240
Note the subprogram doesn't accept a second parameter value lower than 128 and higher than 255. Also there were only 512 character positions in the Coco text screenie.
Within the code above I provide a visual approximation of the cells turned on (for green only) or off (always black). Any "CHR$()" value divisible by 16 was all black, it sucked. :/
To get a color other than green, just add a multiple of 16 up to and including 112.
0 = green
16 = yellow
32 = blue
48 = red
64 = white (it was called buff)
80 = cyan
96 = magenta
112 = orange
With "cocosetdim" the user could set the pixel width and height of the 2x2 graphics cells. Either cannot be higher than 16.
Three guesses what "cocosetdimauto" does.
One limitation is that, as it is written, this must use VGA 16-color graphics mode rather than 32-bit color. It isn't too hard to translate to "_RGB()". The hardest is color attribute #8, orange, which is "_RGB(255, 128, 0)".
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
11-01-2022, 11:38 PM
(This post was last modified: 11-01-2022, 11:42 PM by bplus.)
Oh ha! That's a 50 minute delay you've got installed in there.
I am pressing keys and waiting, this can't be all, oh! look at that _delay!
Screen 12 uses bot 16 colors or RGB (32)
Screen _Newimage(width, height, 12) ' 12 will get both 16 color and rgb
Code: (Select All) Screen _NewImage(800, 600, 12)
For i = 1 To 16
Line (0, (i - 1) * 20)-(_Width, i * 20), i, BF
Next
PS also there's Palette which I don't use but I think you can customize colors 256 of them.
b = b + ...
|