I love the jaggies!
#9
Lightbulb 
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)".
Reply


Messages In This Thread
I love the jaggies! - by mnrvovrfc - 10-26-2022, 03:17 PM
RE: I love the jaggies! - by bplus - 10-26-2022, 04:24 PM
RE: I love the jaggies! - by mnrvovrfc - 10-26-2022, 07:15 PM
RE: I love the jaggies! - by James D Jarvis - 10-26-2022, 04:47 PM
RE: I love the jaggies! - by mnrvovrfc - 10-26-2022, 07:20 PM
RE: I love the jaggies! - by mnrvovrfc - 10-27-2022, 06:06 PM
RE: I love the jaggies! - by bplus - 10-27-2022, 06:34 PM
RE: I love the jaggies! - by mnrvovrfc - 10-27-2022, 11:38 PM
RE: I love the jaggies! - by mnrvovrfc - 11-01-2022, 11:07 PM
RE: I love the jaggies! - by bplus - 11-01-2022, 11:38 PM
RE: I love the jaggies! - by mnrvovrfc - 11-02-2022, 01:10 AM



Users browsing this thread: 2 Guest(s)