Tuesday 9 December 2014

Rocket Raid Under the Hood 9: Hall Of Fame (cont.)

This is the ninth part in a series of posts on digging into the code of the Acornsoft side-scrolling arcade game, Rocket Raid.

Top Eight Name Entry Screen

Having made a brief diversion in the last post to look at some general text printing routines, we now return to code relating to the Hall of Fame. As we saw in this earlier post, after each game the player's score is checked to see if it qualifies for the Top Eight. If it does, then a screen is displayed prompting for their name.
An awesome score of above 1000
gets you into the Top Eight

Displaying the Entry Screen


Since the screen is in MODE 7 teletext, all the content information can be stored as a list of text and control characters, then displayed by calling the "Microsoft string" print routine from the last post

BeebDis labels:
topEightText $0400

Disassembly: 

.topEightText

        EQUS $86             ; Length of all text to display (&86 characters)
        EQUS $16,$07         ; Mode 7
        EQUS $1F,$07,$03     ; Move cursor to (7,3)
        EQUS $86,$9D         ; Background colour to Cyan
        EQUS $84,$8D         ; Text colour to blue, double-height
        EQUS "Congratulations!!"
        EQUS $9C             ; Background colour to Black
        EQUS $1F,$07,$04     ; Move cursor to (7,4)
        EQUS $86,$9D         ; Background colour to Cyan
        EQUS $84,$8D         ; Text colour to blue, double-height
        EQUS "Congratulations!!"
        EQUS $9C             ; Background colour to Black
        EQUS $1F,$03,$07     ; Move cursor to (3,7)
        EQUS $82             ; Text colour to Green
        EQUS "Your score is in the Top Eight."
        EQUS $1F,$07,$0A     ; Move cursor to (7,10)
        EQUS $81,$0A,$81     ; Text colour to Red,
                             ; move down one line, Text colour to Red
        EQUS "Please enter your name:"
        EQUS $1F,$07,$0F     ; Move cursor to (7,15)
        EQUS $86,$9D         ; Background colour to Cyan
        EQUS $84             ; Text colour to blue
        EQUS $1F,$1F,$0F     ; Move cursor to (31,15)
        EQUS $9C             ; Background colour to Black
        EQUS $1F,$0A,$0F     ; Move cursor to (10,15)


.qualified

        LDX #$00             ; Set address of screen
        LDY #$04             ; content (.topEightText)
        JSR printMicrosoftString ; and print it


Fetching the Player's Name


Next, the OSWORD routine for reading keyboard input (also from the last postis called to fetch the player's name. An OSBYTE call is made first to reset the Escape flag.

BeebDis labels:
inputParams $07E0
Disassembly:

        LDA     #$7E            ; 
        JSR     OSBYTE          ; OSBYTE routine &7E (clear Escape condition)

        LDY     #$07            ; X and Y point to

        LDX     #$E0            ; parameter block .inputParams (&07E0)
        LDA     #$E5            ;
        STA     inputParams     ; Store pointer to .inputBuffer (&07E5)
        STY     inputParams+1   ; as the first param
        LDA     #$13            ;  
        STA     inputParams+2   ; Set max characters to 19 (excluding RETURN)
        LDA     #$20            ;
        STA     inputParams+3   ; Minimum acceptable ASCII value=32
        LDA     #$7E            ;
        STA     inputParams+4   ; Maximum acceptable ASCII value=126
        LDA     #$00            ;
        JSR     OSWORD          ; Finally make call to OSWORD routine 0
                                ; (read a line of text from input)

A check is then made to see whether the player pressed RETURN to complete their input, as normal, or hit Escape. If they pressed Escape then the input is set to an empty string.


Copying to the Name Look-up Table


The text input is then copied into the lowest position of the Hall of Fame name table (the "rank 9" position).

It is now ready to be sorted to the correct rank, as covered in this earlier post.

BeebDis labels:
foundCarriageReturn $055B
copyFromBuffer $0567

Disassembly:

        BCC     foundCarriageReturn ; Check if Escape was pressed.

        LDA     #$0D             ; If yes, then store only a carriage return

        STA     inputBuffer      ; in the buffer i.e. an empty string.
.foundCarriageReturn             ;
        LDA     nameLookup       ; 
        STA     stringPtr        ; Point stringPtr (2 bytes) 
        LDA     nameLookup+1     ; to the start of the Hall of Fame's
        STA     stringPtr+1      ; name table.
        LDY     #$13             ; Set counter to 19
                                 ; (want to copy 20 bytes in total)
.copyFromBuffer
        LDA     inputBuffer,Y    ; Copy character from input buffer
        STA     (stringPtr),Y    ; to the lowest rank in the
                                 ; name table (rank 9).
        DEY                      ;
        BPL     copyFromBuffer   ; Copy next character while Y>=0

No comments:

Post a Comment