Find Next Screen

;*********************************************************************
;* JUMP 5000 PICK WHICH SCREEN TO RUN?
;* SCREENTABLE:                  ; Table of screen values used in BAS5010
;*            fdb   1,1,3,4,2,1,1,4,2,5,1,1,1,6,1,1,5,1,1,6,0
;*  Brief description
;*
;* I/O: what is expected and produced
;*
;* Calling Convention: how is this called?
;*
;* Returns:
;*
;* Stack Usage: (when needed) structure of stacked data
;*
;* Calls: Info about routines called
;*
;* Changes: registers destroyed.
;*********************************************************************
BAS5000:                      ; 5000 REM**

BAS5005:                      ; FIXME 5005 POKE&HF5E5,&HE3:PM=1:CR=4:SS=0
            clr   NEXTSCREEN  ; FIXME F5E5 LOADS AS D4 - CHANGED TO E3
            lda   #1          ; FIXME constants can be made into config variables
            sta   PM          ; NUMBER ITEMS PER CATEGORY TO 1
            lda   #4          ; FIXME constants can be made into config variables
            sta   CR          ; 4 CREW REMAINING
            clr   SS          ; SHOW SCREEN 0

BAS5006:                      ; FIXME 5006 GOSUB 6700:EE=0
                              ; FIXME SETUP F53B TO JR 0xF569
            clr   EE          ; FIXME EE = 0 WHAT IS EE?

BAS5010:                      ; 5010 EXEC&HF5B8
                              ; ############################################################################
ASMF5B8:                      ;        LDX     0xF5E5      ;F5B8 2A E5 F5    LD      HL,(0xF5E5)
                              ;        LEAX    1,X         ;F5BB 23          INC     HL
                              ;        TFR     L,A         ;F5BC 7D          LD      A,L
                              ;        CMPA    #$ E        ;F5BD FE E4       CP      0xE4
                              ;        LBNE    0xF5C3      ;F5BF 20 02       JR      NZ,0xF5C3
                              ;        TFR     0xD0,L      ;F5C1 2E D0       LD      L,0xD0
                              ;        LDA     ,X          ;F5C3 7E          LD      A,(HL)
                              ;        STA     0xF5E7      ;F5C4 32 E7 F5    LD      (0xF5E7),A
                              ;        STX     0xF5E5      ;F5C7 22 E5 F5    LD      (0xF5E5),HL
                              ;        RTS                 ;F5CA C9          RET
                              ; ### TABLE OF SCREEN/LEVEL VALUES?
                              ;         TFR     0x0301,U    ;F5D0 01 01 03    LD      BC,0x0301
                              ;         INCB                ;F5D3 04          INC     B
                              ;         STA     ,U          ;F5D4 02          LD      (BC),A
                              ;         TFR     0x0401,U    ;F5D5 01 01 04    LD      BC,0x0401
                              ;         STA     ,U          ;F5D8 02          LD      (BC),A
                              ;         DECB                ;F5D9 05          DEC     B
                              ;         TFR     0x0101,U    ;F5DA 01 01 01    LD      BC,0x0101
                              ;         TFR     0x01,B      ;F5DD 06 01       LD      B,0x01
                              ;         TFR     0x0105,U    ;F5DF 01 05 01    LD      BC,0x0105
                              ;         TFR     0x0006,U    ;F5E2 01 06 00    LD      BC,0x0006
                              ;         BCS     >           ;F5E5 -
                              ;         LBSR    0x01F5
                              ; !       ***     Jump here   ;**** D4 F5 01    CALL    NC,0x01F5

            ldb   NEXTSCREEN  ; load the value of the offset into the table
            incb              ; move the offset one more
            cmpb  #20         ; did we hit 00 at the end of the table?
            bne   EXIT5010    ; not at the end of the table, use the B we got
            clrb              ; yep, hit end of table, so reset offset to 0 back at start of table
EXIT5010:   stb   NEXTSCREEN  ; save our offset to use in B
            ldx   #SCREENTABLE ; load address of table of screens to show in order
            abx               ; now get that table value address read
            lda   ,X          ; load table value into accumulator

BAS5020:                      ; 5020 ON PEEK(&HF5E7) GOSUB 100,2000,4000,6000,6500,8800,6000,8800
                              ; MOVE THROUGH TABLE OF SCREENS AS GAME PROGRESSES?
                              ; F5E7 LOADS AS 01 TO GO TO MAIN GAME LOOP FIRST
                              ; SCREEN 1 - 100 MAIN
                              ; SCREEN 2 - 2000 TIME TRIAL
                              ; SCREEN 3 - 4000 DEMO1
                              ; SCREEN 4 - 6000 TIME TRIAL
                              ; SCREEN 5 - 6500 GRAPHIC MULTICOLOR ALIEN SITTING STILL
                              ; SCREEN 6 - 8800 GRAPHIC RED ALIEN BOUNCING BACK AND FORTH
                              ; SCREEN 7 - 6000 GRAPHIC MULTICOLOR ALIEN SITTING STILL
                              ; SCREEN 8 - 8800 GRAPHIC RED ALIEN BOUNCING BACK AND FORTH

                              ; FIXME replace this mess with a jump table by offset
                              ; SCREEN 7 AND 8 in GOSUB are never called by number from table
            cmpa  #1          ; is next screen #1?
            bne   CHKSCN2     ; no, go check next
            jsr   BAS0100     ; yes, gosub line 100 - main game screen
            jmp   BAS5025     ; go check EE when done
CHKSCN2:
            cmpa  #2          ; is next screen #2?
            bne   CHKSCN3     ; no, go check next
            jsr   BAS2000     ; gosub line 2000 - main time trial screen
            jmp   BAS5025     ; go check EE when done
CHKSCN3:
            cmpa  #3          ; is next screen #3?
            bne   CHKSCN4     ; no, go check next
            jsr   BAS4000     ; yes, gosub line 4000 demo 1
            jmp   BAS5025     ; go check EE when done
CHKSCN4:
            cmpa  #4          ; is next screen #4?
            bne   CHKSCN5     ; no, go check next
            jsr   BAS6000     ; yes, gosub line 6000 - time trial intro
            jmp   BAS5025     ; go check EE when done
CHKSCN5:
            cmpa  #5          ; is next screen #5?
            bne   CHKSCN6     ; no, go check next
            jsr   BAS6500     ; yes, gosub line 6500 - graphic alien sitting still
            jmp   BAS5025     ; go check EE when done
CHKSCN6:
            cmpa  #6          ; is next screen #6?
            bne   CHKSCN7     ; no, go check next
            jsr   BAS8800     ; yes, gosub line 8800 - graphic alien bouncing around
            jmp   BAS5025     ; go check EE when done
                              ; FIXME we should never fall through here
CHKSCN7:    bra   CHKSCN7     ; ERROR - HALT
CHKSCN8:    bra   CHKSCN8     ; ERROR - HALT

BAS5025:                      ; 5025 IF EE=1 THEN GOTO 5000
            lda   EE          ; load EE
            cmpa  #1          ; compare EE to 1
            bne   BAS5030     ; not equal, go to next line 5030
            jmp   BAS5000     ; was equal, go to line 5000

BAS5030:                      ; 5030 GOTO 5010
            jmp   BAS5010

Return to Nostromo