Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Andrew Davie

#406
Programming / Higher than 60Hz on NTSC
17 Sep 2023, 08:35 PM
I was thinking about ChronoColour and the effective 20Hz "shimmer" -- that is, changing colours in triplets at 60Hz --> a 20Hz cycle.  If the frame rate increased, then the shimmer would become less obvious. And then I realised I don't think I've seen much discussion about increasing the frame rate on NTSC. Of course we do PAL60, which is pretty much a standard. But what about (say) NTSC 66?  I wonder just how much we can go above 60Hz and still be compatible with most CRT NTSC TVs?
#407
A couple of years ago I was working on my chess display, and wanted to put some text overlay on top of the asymmetric playfield. I did not manage to get this working - simply not enough processing time on the scanline to change 6 PF registers + 6 sprite shapes + 3 colour (PF, sprite 0, sprite 1).  However, I did manage to get it working if I used a mirrored playfield and dropped the left/right 4 pixels.

So, this is that - a 32-PF pixel asymmetric playfield with colour change on every scanline + an overlaid 6-sprite routine also with a colour change on every line.  I found only one horizontal position where this all worked perfectly, though I have not extensively tested to try other positions. The positioning is somewhat determined by the positions in which PF writes must be updated, and also of course the sprite graphics writes.  What you see here is a bit of luck; my first implementation did not work (sprites garbled), but the second - after a little bit of shuffling of the kernel - worked perfectly. 

Here's the kernel code...


                    ldx #%00110011
                    stx NUSIZ0                      ; three copies close, missile x8
                    stx NUSIZ1                      ; three copies close, missile x8
                    stx VDELP0                      ; vertical delay on
                    stx VDELP1                      ; vertical delay on

OverScanMenu

    ; axiom: D2 of X == 1

                    sta WSYNC
                    stx VBLANK              ; video output off (D2 of X is 1 always!)


                    ldx kernel
                    cpx currentKernel
                    beq thisKernel

                    jmp startAnyKernel
thisKernel


                    ldx tv_type
                    lda TimerOS,x
                    clc
                    adc #1
                    sta TIM64T              ; set timer for OS

                    lda #_DS_AUDV0
                    sta AUDV0
                    lda #_DS_AUDC0
                    sta AUDC0
                    lda #_DS_AUDF0
                    sta AUDF0

                    lda #_DS_AUDV0
                    sta AUDV1
                    lda #_DS_AUDC0
                    sta AUDC1
                    lda #_DS_AUDF0
                    sta AUDF1


    IF _ENABLE_ATARIVOX
        jsr speakJet
    ENDIF

                    ldy #_FN_MENU_OS
processArmOSMenu    jsr CallArmCode
                    ldy #_FN_MENU_IDLE
                    jsr CallArmCode
                    ;jsr safeTimerCheck
                    ;tmp bcs processArmOSMenu

safeTimerWait2      lda INTIM
                    bpl safeTimerWait2
                    ;jsr safeTimerWait


VerticalSyncMenu

                    ldy #2

                    ldx tv_type
                    lda TimerVB,x

                    sty WSYNC

; --- start scanline 1 of Vertical Sync ---

                    sty VSYNC           ; turn on Vertical Sync signal
                    sta TIM64T
                    sty WSYNC

; --- start scanline 2 of Vertical Sync ---

                    ; use otherwise wasted time to zero out some TIA registers

                    ldx #0              ; 2  2
                    stx PF0             ; 3 17
;                    stx CTRLPF          ; 3 26
                    stx WSYNC           ; 3 29/0

; --- start scanline 3 of Vertical Sync ---



    ; IF _ENABLE_ATARIVOX
    ;     jsr speakJet
    ; ENDIF


                    ldy #_FN_MENU_VB
                    stx WSYNC           ; end of VerticalSync scanline 3
                    stx VSYNC           ; turn off Vertical Sync signal
                    jsr CallArmCode

                    ldx #1
vbSetInitialMenu    lda #DSCOMM                 ; P1_X, P0_X

PosObject

    ; A = X position value
    ; X = 0=P0, 1=P1, 2=M0, 3=M1, 4=Ball

                    sec
                    sta WSYNC
DivideLoop          sbc #15
                    bcs DivideLoop

                    eor #7
                    asl
                    asl
                    asl
                    asl
                    sta.wx HMP0,X
                    sta RESP0,X

                    dex
                    bpl vbSetInitialMenu

                    lda #DSCOMM
                    sta tv_type                 ; _TV_TYPE = NTSC, PAL, PAL-60, SECAM
                    lda #DSCOMM
                    sta kernel
                    lda #DSCOMM
                    sta COLUBK

                    sta WSYNC
                    sta HMOVE




processArmVBMenu    ldy #_FN_MENU_IDLE
                    jsr CallArmCode
                    ;jsr safeTimerCheck
                    ;tmp bcs processArmVBMenu
                    ;jsr safeTimerWait
safeTimerWait3      lda INTIM
                    bpl safeTimerWait3


                    ldx #0
                    stx VBLANK              ; video output on
                    stx PF0

                    ldx #%00000001
                    stx CTRLPF              ; reflect PF

                    lda #_DS_COLUPF
                    sta COLUPF

                    sta WSYNC
    ;                sta WSYNC
                    jmp FASTJMP1


_MENU_KERNEL

;@3

                    lda #_DS_PF1_LEFT
                    sta PF1                         ; 5
                    lda #_DS_GRP0a
                    sta GRP0                        ; 5
                    lda #_DS_GRP1a
                    sta GRP1                        ; 5
                    lda #_DS_GRP0b
                    sta GRP0                        ; 5

                    lda #_DS_GRP1c                  ; 2
                    tay                             ; 2

                    lda #_DS_PF2_LEFT
                    sta PF2                         ; 5

                    lda #_DS_GRP0c                  ; 2
                    tax                             ; 2
                    lda #_DS_PF1_RIGHT
                    sta PF1                         ; 5
;@41
                    lda #_DS_PF2_RIGHT              ; 2
                    nop                             ; 2
                    sta PF2                         ; 3

                    lda #_DS_GRP1b                  ; 2
                    sta GRP1                        ; 3
                    stx GRP0                        ; 3
                    sty GRP1                        ; 3
                    sta GRP0                        ; 3

;@62

                    lda #_DS_COLUP0                 ; 2
                    sta COLUP0                      ; 3
                    sta.w COLUP1                    ; 4

                    lda #_DS_COLUPF                 ; 2
                    sta COLUPF                      ; 3
;@76=0

                    jmp FASTJMP1                    ; 3

;@3--> start of line again :)


_EXIT_MENU_KERNEL

                    ldx #2
                    stx VBLANK
                    ldy #0
                    sty PF1
                    sty PF2

                    jmp OverScanMenu

; EOF


As you can see, it's CDFJ-centric, using data streams to retrieve graphics data rapidly.  The "magic" starts at the label _MENU_KERNEL.

I'm happy for others to use this idea/code. A simple acknowledgement if you use my code would be all I'd expect.

Here's a screenshot of it in action - you see the menu text right-of-center. In reality, this is a vertical strip of 6 sprites occupying the entire screen height, so you can put graphics/text there to your heart's content.




#408
Full source code for WenHop is available at Github WenHop Repository - released under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license..

I'm very lenient with regard to sharing my code/creations. I do require attribution and respect of my IP. I am very happy to help you understand this project. You will have a fair bit of effort required to get this building (tool installation, etc).
#409
Quote from: MachoDrone on 12 Sep 2023, 01:42 PM    LDA #2    ; LoaD the Accumulator with the value 2, which is the number of cycles to wait
    STA VSYNC ; Vertical SYNChronization, waits until the vertical blanking period starts

    LDA #0    ; LoaD the Accumulator with the value 0, which is the number of cycles to wait
    STA VSYNC ; Once the three scanlines are complete, it stops the vertical retrace by loading zero into the register VSYNC


The coments are incorrect in the above two lines. The value loaded into the accumulator is not a count of cycles.  The VSYNC register is a control register which uses particular bits to do various stuff. When you store 0 to that register you clear all the bits. When you store 2 to that register, you are actually setting bit #1. (bit0=1, bit1=2, bit2=4, bit3=8.... bit7=128).  So, what does bit 1 of VSYNC do?

As it happens, *only* bit 1 in VSYNC is actually used - and it controls the generation of a VSYNC signal. Setting bit1 (also called D1) to 1 will enable VSYNC.  Setting to 0 disables.  Some '2600 registers use bit values like this, and some are simply strobe registers (WSYNC is a strobe register) which simply don't care what you write to them - just writing anything causes them to "trigger".
#410
Quote from: MachoDrone on 12 Sep 2023, 01:42 PM    LDA #36       ; Now it counts 36 scanlines using the X register...

In this line you are loading 36 into the accumulator, when it should be LDX into the x register.
Because you have not correctly initialised X, your scanline count depends on whatever X happens to be.
Almost certainly your major problem/bug right there.
#411
Use "Ctrl-L" in Stella, or "F7" in Gopher to bring up an overlay giving you some stats/info on the frame being generated. In particular, it looks to me like you're not generating a 262 scanline screen there.  Of the two, I would trust Gopher in terms of showing you what it will actually look like on a TV.

An option is to share all your source code - usually people in forums will be very helpful in diagnosing.
#412
Quote from: MachoDrone on 12 Sep 2023, 11:23 PMthat's beautiful. how many lines of code is that?

About 20,000
#413
Quote from: MachoDrone on 12 Sep 2023, 01:42 PMoh, i was just showing the colors since the green sea of comments were so prominent.
you may know this, but there is a photo attachment limit of 0.2MB in your current forum settings, so i just made the pic tiny enough to see colors.

Now fixed.

;    The position (or "address") of this box is known as PC (Program Counter) and it is a value between 0 and 65535 (16-bit, or 4 hexadecimal digits)

Almost.  The PC is a register which contains the address.  So the position is not called the program counter;  the position is the address, and the program counter contains an address giving the current code location being executed.

;                  X:  8-bit register used for arithmetic operations
;                  Y:  8-bit register used for arithmetic operations

X and Y are known as index registers and they have only increment and decrement (by one) arithmetic capability.  Typically they are used to combine with an address to give the ability to index into tables, graphics data, etc.

;  Bit 4: The B (Break) flag is set when a BRK instruction has been executed, and an interrupt has been generated to process it.
;  Bit 3: The D (Decimal) flag is used to put the 6502 into BCD (Binary Coded Decimal) mode. Very Useful.
;  Bit 2: The I (Interrupt) flag is used to mask/disable interrupts in the 6502, but is unused in the 6507.

The '2600 does not generate break or interrupts - although IIRC brk can be triggered manually by executing instruction $00.

    ORG $F000  ; --- the following instructions start at the hexadecimal address $F000, which is the reset vector for the 6507 processor

No. Terminology is important here.  The vectors are the group of words at the end of the ROM (non-maskable interrupt vector, break vector, reset vector).  Those words point to anywhere in memory and the 6507 will load the address from those vectors when the associated event happens. So the reset vector can point to anywhere in your code, wherever you happen to put the startup code you want to run on reset.

START:      ; label used by the reset vector -- ALWAYS USE COLON for ease of searching labels in your code

There are some style differences bewteen developers here. One is the use of colon. I hate it, and do not use it at all.  Many use it.  You do not need to have a label on its own line; you can follow it by a space and a mnemonic (e.g., "START SEI"), And while we're at it, ALL UPPERCASE MNEMONICS/LABELS is like shouting. Hard to read, and unnecessary.  So many of the experienced developers will use lowercase - but again, a style thing. I'm more likely to help you with your code if it's lowercase ;)

On the subject of "finding" the definition of a label, in Atari Developer Studio, I just ctrl-click on the label usage, and it jumps right to the definition for me. Using this IDE, at least, there's absolutely no need to put the : at the end of the definition line.

    SEI      ; SEt internal Interrupt flag bit, commands the processor to not accept external interrupts via its INT pin (no INT pin on 6507)

The above is standard, and good practice -- but the '2600 does not actually generate non-maskable interrupts so the SEI is superfluous.

    DEX      ; DEcrement the value of X (by 1?)

Yes. INX, DEX, INY, DEY, INC address, DEC address... these are all +/-1
There is no equivalent for the accumulator, so you have to manually add or subtract 1.
#414
Forum Meta / code block font
12 Sep 2023, 03:03 PM
I made the font size in code blocks a bit smaller.
Let me know if this doesn't work for you on your setup.
#415
Forum Meta / Re: forum email settings
12 Sep 2023, 02:59 PM
I'll look at fixing that soon.
#416
Quote from: MachoDrone on 12 Sep 2023, 01:24 PMimma gonna accomplish something small with my own code, just to say i did it.

Hard to see the image/contents.
Typically, use the <> code icon when editing, and paste a copy of your code in there... example:

;===============================================================================

    ORG $7FED
    RORG $FFED

ARM_DIRECT_DATA_END

                    jmp InitSystem

                    ds 12, 0                        ; reserve space for CDFJ registers

                    .WORD InitSystem
                    .WORD InitSystem

;===============================================================================
; Display Data
;----------------------------------------
;  4K of RAM shared between the 6507 and ARM.
;
;  NOTE: anything prefixed with _ ends up in main/defines_from_dasm_for_c.h
;        so that the C code will have the same values as the 6507 code
;===============================================================================

    SEG.U DISPLAYDATA
    ORG $0000

_DS_TooARM

_RUN_FUNC          ds 1        ; function to run
_SWCHA              ds 1        ; joystick directions to ARM code
_SWCHB              ds 1        ; console switches to ARM code
_INPT4              ds 1        ; left firebutton state to ARM code
;_INPT5              ds 1        ; right firebutton state to ARM code

#417
Woodgrain Wizard Tiki

I worked a bit on this a while back, and haven't promoted it too much. I'd like to see it become a central store of technical information about '2600 programming, and I invite you all to contribute.
#418
Quote from: Thomas Jentzsch on 11 Sep 2023, 07:20 PMNo 3D-printing of wood yet? ;D

You can buy 'wood' filament for 3D printing. But it doesn't really impress me.
#419
That's awesome. I wish I had the machinery to let me do that kind of thing.
#420
Forum Meta / Re: Thoughts on our new forum
11 Sep 2023, 06:50 PM
Quote from: Thomas Jentzsch on 11 Sep 2023, 06:32 PMThey do not give any credit for using Stella in their 2600+, let alone donate to the Stella project. Etc.

So what is the "legal" side of that?  Are they allowed to create a commercial product using Stella, especially without acknowledgement?