Here is some modex code I found
Posted: Mon Apr 04, 2011 1:48 pm
I found this by Jason Plackey on a web site thought I'd share:
Hope this helps with modex.
Code: Select all
DECLARE SUB ModeX () '
DECLARE SUB OutPort (PortAddr&, vh%, vl%) '
DECLARE SUB Standard () '
DECLARE SUB SetVOffset (Offset&) '
'
SCREEN 13: DEF SEG = &HA000: CALL ModeX'
'
FOR count% = 0 TO 63'
redval& = count%'
greenval& = 256 * count%'
blueval& = 65536 * count%'
rgbval& = blueval& + greenval& + redval&'
PALETTE count%, redval&'
PALETTE count% + 64, greenval& '
PALETTE count% + 128, blueval& '
PALETTE count% + 192, rgbval& '
NEXT count%'
'
FOR Offset& = 0 TO 15999'
rgbbase% = Offset& MOD 64'
POKE Offset&, rgbbase%'
POKE Offset& + 16000, rgbbase% + 64 '
POKE Offset& + 32000, rgbbase% + 128'
POKE Offset& + 48000, rgbbase% + 192'
NEXT Offset&'
'
Offset& = 0: OffsetInc% = 80: Frame% = 0'
'
DO'
Offset& = Offset& + OffsetInc%'
CALL SetVOffset(Offset&): WAIT &H3DA, 8'
Frame% = Frame% + 1'
IF Frame% = 99 THEN OffsetInc% = 81'
IF Frame% = 199 THEN OffsetInc% = 79'
IF Frame% = 299 THEN OffsetInc% = 80'
IF Frame% = 499 THEN OffsetInc% = -80'
IF Frame% = 599 THEN OffsetInc% = -79'
IF Frame% = 699 THEN OffsetInc% = -81'
IF Frame% = 799 THEN OffsetInc% = -80'
IF Frame% = 899 THEN '
CLS : PALETTE'
CALL SetVOffset(0): CALL Standard'
END'
END IF'
FOR delay% = 1 TO 10: NEXT delay%'
LOOP'
'
' Regarding the example code... Change the delay% value to
'accommodate your CPU's speed. The TIMER function is
'relatively inaccurate when dealing with fractions of a
'second, and I had insufficient space to include my own timer
'routine.
'
' If you have any questions, feel free to ask.
'Happy coding! Jason Plackey
'
'
'
SUB ModeX '
CALL OutPort(&H3C4, 6, 4): CLS '
CALL OutPort(&H3D4, 227, 23)'
CALL OutPort(&H3D4, 0, 20)'
CALL OutPort(&H3C4, 15, 2)'
END SUB'
'
SUB OutPort (PortAddr&, vh%, vl%) '
OUT PortAddr&, vl%: OUT PortAddr& + 1, vh%'
END SUB'
'
SUB SetVOffset (Offset&) '
V& = Offset&'
CALL OutPort(&H3D4, V& \ 256, 12)'
CALL OutPort(&H3D4, V& AND 255, 13)'
END SUB'
'
SUB Standard '
CALL OutPort(&H3C4, 14, 4)'
CALL OutPort(&H3D4, 163, &H17)'
CALL OutPort(&H3D4, 64, &H14)'
CALL OutPort(&H3C4, 15, &H2)'
END SUB'