Homebrew:F8 of Nations

From veswiki
Jump to: navigation, search

F8 of Nations, color version.

Smallest Fairchild Channel F game ever with only 37 Bytes on the black and white version. Uses almost only BIOS routines.

Unfortunately the original description has been lost but it was something about saving the Earth by pressing the sequence showed as soon as possible.

The only game to date that uses the console buttons instead of a hand controller.

; F8 of Nations
; written by nycurt

        processor f8

; BIOS Calls ;

prompt                  =          $0099
clrscrn                 =          $00D0
IncP1Score              =          $02AC

; Main Program Code ;

; Program Entry ;

        org     $800

        LR        $5,A  ; $55 Needs to be at beginning of cartridge
        LR        $A,A  ; Can be anything in this byte. In early versions this was used as code

        IF 0
If you add the following code to the beginning of the game, the gameplay will be in color and it 
will keep track of your score (which wraps around when you get to 99).


        IF 0
        li  $99
        LISU 2                             ; 02b0 6e
        LISL 6                             ; 02b0 6e
        lr      I,A
        li      $d6
        lisu    3
        lr      S,A
        lr      3, A
        pi      clrscrn
        LISU 2                             ; 02b0 6e
        pi IncP1Score


        li        $45    ; Bit 6 in this byte is used to emit a sound when written to port 5
        outs    5          ; Play a sound

; Store $45 in reg0 - $4 specifies blue and $5 the '5' character to the prompt func. This 
; register will be decremented 1 to 4 times to select a number from '1' to '4'
        lr        $0,A  

; And the byte referenced by the DC with $3 - this gives a number from 1 to 4 for the game
        lis             $3
; The DC is used in addressing memory. The H register will have been initialized to 0 by the BIOS
; before we are started, so we point the DC at 0. Each successive round will advance the DC by
; one byte. The number that is selected (1-4) is determined by the low-order three bits in the
; byte loaded from the DC. If the user plays for a very long time the DC will increment beyond
; valid memory.
        lr        DC,H
        nm                              ; and #$3 with the memory referenced by the DC
        lr        H,DC
; Loop control variable initialized with the # that the user must match
; The value $10 will be shifted right each time through the loop and will match the correct 
; input value for the button that corresponds to the number.
        lr              $9,A
        li        $10
        sr        1
        ds        $0      ; Decrement the value that will be sent to prompt (initialized to $45)
        ds        $9
        bc        loop
        lr      $9,A    ; This has the bit corresponding to the correct button the user must press
        pi        prompt  
; This displays the number (with '?'), and waits for input and delays briefly
; There is no need to write $0 to port 0 to prepare it for input... the prompt
; subroutine will have done so for us... see instructions at $764 in BIOS
        ins      0         ; Retrieve console button state
        com                      ; Complement it ($1=but1,$2=but2,$4=but3,$8=but4)
        ni        $F      ; Clip off the top four bits
        outs    5          
; Clear the sound register... We know the relevant top two bits of A are clear
        xs        $9      ; XOR with Reg 9 which contains the correct input
        bnz      delayforever ; User lost the game. Freeze
        br        nextround ; The user entered the correct response. Torture them some more

        org $fff                ; added only to set a useable rom-size in MESS
        .byte   $ff