Example

circle example 1

3

nitrofurano 2022-12-21 19:09

filled circles

circlef1a.nx | Open in app
2022-12-21 19:09

GAMELEGEND 2022-12-21 20:23

jeez you are releasing programs faster than was8bit


SP4CEBAR 2022-12-21 20:34 (Edited)

Feel free to use my new HLINE( X1, Y, X2, C) (horizontal line) subprogram for faster performance
this one uses overlay, I made another variant for XOR which is slightly slower

'S E T U P
'DEFINE ROM FOR FASTER PIXEL PROCESSING
DIM GLOBAL LLINE_ROM(7),RLINE_ROM(7),PIXEL_ROM(7)
FOR I=0 TO 7
  LLINE_ROM(I)= 255 XOR 2^(7-I)-1
  RLINE_ROM(I)= 2^(8-I)-1
  PIXEL_ROM(I)= 2^(7-I)
NEXT I

'S U B P R O G R A M S

SUB OVERLAY2(A0,C0,C1)
  A1=A0+8
  B0=PEEK(A0)
  B1=PEEK(A1)
  M=255 XOR (C0 OR C1)
  POKE A0,(B0 AND M) OR C0
  POKE A1,(B1 AND M) OR C1
END SUB

SUB HLINE(X0,Y,X1,C)
  'SAFETY: RECTIFY ORDER AND BOUNDARIES
  IF X0>X1 THEN SWAP X0,X1
  X0=MAX(0,MIN(127,X0))
  X1=MAX(0,MIN(127,X1))
  Y =MAX(0,MIN(127,Y ))

  'PREPARE: COLOR, 8-PIXEL SEGMENT, ADDRESS, QUANTIZED COORDINATES
  C0=C MOD 2
  C1=C\2
  C0L=C0*255
  C1L=C1*255
  A0=$8000+(Y\8)*256+(Y MOD 8)
  X0Q=(X0\8)*8
  X1Q=(X1\8)*8
  IF X0Q=X1Q THEN
    A=$8000+(Y\8)*256+X0Q*2+(Y MOD 8)
    N0=RLINE_ROM(X0 MOD 8)
    N1=LLINE_ROM(X1 MOD 8)
    N=N0 AND N1
    'N=N0
    CALL OVERLAY2(A,N*C0,N*C1)
    EXIT SUB
  END IF

  'LEFT SEGMENT: ADDRESS, BINARY LINE, DRAW
  A=A0+X0Q*2
  N=RLINE_ROM(X0 MOD 8)
  CALL OVERLAY2(A,N*C0,N*C1)

  'LINE: ADDRESS, DRAW (DOESN'T NEED OVERLAY AND SEGMENT IS ALWAYS 255)
  FOR X=X0Q+8 TO X1-8 STEP 8
    A=A0+X*2
    POKE A  ,C0L
    POKE A+8,C1L
  NEXT X

  'RIGHT SEGMENT
  A=A0+X1Q*2
  N=LLINE_ROM(X1 MOD 8)
  CALL OVERLAY2(A,N*C0,N*C1)


  'REQUIRED ROM DEFINITIONS:
  'RLINE_ROM(I MOD 8) =         2^(8-(I MOD 8))-1
  'LLINE_ROM(I MOD 8) = 255 XOR 2^(7-(I MOD 8))-1
  'BUG MEMORIAL: (X0\8)*8 INSTEAD OF X0, FIRST CASE WAS SHOVED UNDER THE RUG BY OFFSETS
  'DEBUGGING TOOL:
  'CALL PLOT(X0,Y,3)
  'CALL PLOT(X1,Y,3)
END SUB


nitrofurano 2022-12-21 20:58

thanks a lot! but i also need to understand what is coded there! :)


SP4CEBAR 2022-12-21 22:56 (Edited)

You don't need to understand all of it, to be able to use it all you really need to know is that it draws a horizontal line between X coordinates "X1" and "X2" at Y coordinate "Y" with 2-bit color "C": CALL HLINE( X1, Y, X2, C)

And make sure to run that bit of setup code before using it

If you really want to understand all of it:
in NX characters: eight pixels are stored in a byte, horizontally
This program generates the bytes that have the right pixels turned on
At the start it looks something like this: "00011111", at the end something like this: "11110000", and in between... well it's always "11111111" (255 in decimal) most pixels are in between so this makes it pretty fast

It can also generate really short lines using bitwise AND: for example "111111100" AND "00011111" gives "00011100"


was8bit 2022-12-22 05:58 (Edited)

@gamelegend... if I wasn't working so many hours, the 30 some games that are only partials would have been posted by now... But I am trying not to post a lot of unfinished games...

I'm happy to see some fun activity :)


nitrofurano 2022-12-22 17:40

i didn't try it yet, but i coded an example using an unoptimized version of hline that perhaps might be helpful to test your code

hline01b.nx | Open in app
2022-12-22 17:40

SP4CEBAR 2022-12-22 21:31

Nice


Log in to reply.