Jump to content

Recommended Posts

I am developing a new language that I have been introducing here:

 

After the Atari 8-bit, I am now targeting it at the 2600. I just posted the first demo here:

Here is the source code:

 
unsafe!!! constant reference volatile byte! [
    ; TIA

    VSYNC= ~0000
    VBLANK
    WSYNC
    COLUBK= ~0009
    PF0= ~000D
    PF1
    PF2
    GRP0= ~001B
    GRP1
    ENAM0
    ENAM1
    ENABL
]

vertical-sync-bit= %0000'0010

VBLANK:  ; Set beam to on to use the entire vertical-blank overscan area
    ENABL:  ; Ball off
    ENAM1: ENAM0:  ; Missiles off
    GRP1: GRP0:  ; Players off
    PF2: PF1: PF0: 0  ; Playfield off; we only use the background

byte! [jiffies colour]

forever [
    VSYNC: WSYNC: vertical-sync-bit  ; Wait for end of scanline, then start vertical sync

    ; Vertical sync pulse.
    ; This lasts 3 scanlines, where some small work can be done to set up the next screen.

    colour: jiffies  ; Begin colour gradient, shifted by jiffy counter

    ; Wait three scanlines, then end vertical sync, continue vertical blank
    VSYNC: WSYNC: WSYNC: WSYNC: 0

    ; Vertical blank area, followed by the visible display area,
    ; followed by another vertical-blank overscan area.
    ; PAL and SECAM officially have 45 + 228 + 36 scanlines here, NTSC has 37 + 192 + 30.
    ; We generate 283 scanlines (plus the 3 for vertical sync), for a display frequency of 55Hz,
    ; inbetween PAL/SECAM and NTSC. It will work on all, if you have a tolerant television set.

    ; The first scanline is used for the setup overhead of the LOOP,
    ; so it gets the last colour wrapped over from the last scanline of the previous screen.
    ; Being the first line of the vertical blank overscan area, it is normally not visible.

    loop 282 [COLUBK: WSYNC: overflow increment colour]  ; Increment background colour for every scanline

    overflow increment jiffies
]

Here are some artifacts of the compilation. The assembler listing:

https://language.meta.frl/examples/platforms/Atari/2600/rainbow.list

A VICE labels file, for debuggers:
https://language.meta.frl/examples/platforms/Atari/2600/rainbow.labels

The memory sections map:
https://language.meta.frl/examples/platforms/Atari/2600/rainbow.map

 

It's my second 2600 program; please be gentle. ?

 

The language will be cross-platform on as many systems as possible. 2600 programs are developed by cross-compiling. In many cases, it is also needed to pre-compute data for a 2600 program. You will be able to write such tools in the same language, on your PC or Mac or other favourite system.

 

rainbow.thumb.png.94619ee576d5226a5b3ff18bda93b604.png

Edited by Kaj de Vos
Added screenshot
  • Like 6
Link to comment
Share on other sites

Rainbow assembly

 

The language has an integrated assembler, so we could also write Rainbow like this:

 

https://language.meta.frl/examples/platforms/Atari/2600/rainbow-assembly.rom
https://language.meta.frl/examples/platforms/Atari/2600/rainbow-assembly.list
https://language.meta.frl/examples/platforms/Atari/2600/rainbow-assembly.labels
https://language.meta.frl/examples/platforms/Atari/2600/rainbow-assembly.map

 

 
unsafe!!! [
    constant reference volatile byte! [
        ; TIA

        VSYNC= ~0000
        VBLANK
        WSYNC
        COLUBK= ~0009
        PF0= ~000D
        PF1
        PF2
        GRP0= ~001B
        GRP1
        ENAM0
        ENAM1
        ENABL
    ]

    vertical-sync-bit= %0000'0010

    LDA 0
    STA PF0     ; Turn playfield off; we only use the background
    STA PF1
    STA PF2
    STA GRP0    ; Players off
    STA GRP1
    STA ENAM0   ; Missiles off
    STA ENAM1
    STA ENABL   ; Ball off
    STA VBLANK  ; Set beam to on to use the entire vertical-blank overscan area

    byte! jiffies

    forever:
        STA WSYNC  ; Wait for end of scanline
        LDA vertical-sync-bit  ; Start vertical sync
        STA VSYNC

        ; Vertical sync pulse.
        ; This lasts 3 scanlines, where some small work can be done to set up the next screen.

        LDX jiffies  ; Begin colour gradient, shifted by jiffy counter

        ; Wait three scanlines
        STA WSYNC
        STA WSYNC
        STA WSYNC
        ; End vertical sync, continue vertical blank
        LDA 0
        STA VSYNC

        ; Vertical blank area, followed by the visible display area,
        ; followed by another vertical-blank overscan area.
        ; PAL and SECAM officially have 45 + 228 + 36 scanlines here, NTSC has 37 + 192 + 30.
        ; We generate 283 scanlines (plus the 3 for vertical sync), for a display frequency of 55Hz,
        ; inbetween PAL/SECAM and NTSC. It will work on all, if you have a tolerant television set.

        TAY  ; A is still 0

        loop-256:
            INX  ; Increment colour for every scanline
            STA WSYNC
            STX COLUBK  ; Colour background
        DEY
        BNE loop-256

        LDY 26

        loop-26:
            INX
            STA WSYNC
            STX COLUBK
        DEY
        BNE loop-26

        INC jiffies  ; Count display frames
    JMP forever
]

 

More efficient code can be written this way, but it's clearly more elaborate than the high-level language.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...