~chickendude/z80monopoly/trunk

« back to all changes in this revision

Viewing changes to monoMenu.asm

  • Committer: chickendude
  • Date: 2012-01-23 02:54:05 UTC
  • Revision ID: chickendude-20120123025405-tjxf8mqey9l64i2t
Menu scrolling finally fixed, a few small bugs taken care of, small optimizations. Now to handle selecting scrollable menu choices...

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    
17
17
    inc (hl)            ;hl = firstRow
18
18
    ld a,(hl)
19
 
    cp 7
20
 
    jr nz,tK_skip       ;if firstRow!=8, we can exit
 
19
    cp 6
 
20
    jr nz,tK_skip       ;if firstRow!=6 (the next row), we can exit
21
21
     xor a
22
22
         ld (hl),a       ;reset firstRow to 0
23
23
;shift gbuf up 6 pixels
32
32
     inc de
33
33
     ld (hl),a                  ;byte to copy
34
34
         ldir                           ;erase the space where we'll draw the text
35
 
     
 
35
 
36
36
     ld hl,letRow
37
37
     ld (hl),49                 ;fill in the text at row 49
38
38
         ld hl,currentLine      ;advance a line
40
40
     add a,8                    ;current line + 8: we want to draw the text below
41
41
     ld c,a                             ;b should still be 0 from ldir
42
42
     inc (hl)
 
43
tK_updateText:
43
44
     ld hl,newLineStorage
44
45
     add hl,bc                  ;newLineStorage + currentLine+7: find position of the text stored below
 
46
     ld b,0
45
47
     ld c,(hl)
46
48
         ld hl,textBuffer
47
49
         add hl,bc
50
52
    call copyTextToScreen
51
53
    call drawGbuf
52
54
    ret
53
 
 
54
 
textKeys:
55
 
    ld de,w2_loop
56
 
    push de
57
 
    ld hl,firstRow
58
 
    rra
59
 
    jr nc,tK_down
60
 
    bit 2,a         ;normally up would be bit 3, but we have the rra
61
 
    jr z,tK_up
62
 
    ret
63
55
 
64
 
tK_up:
 
56
tK_up:
65
57
    ld a,(currentLine)  ;find which line in the text we're currently at
66
58
    or a
67
59
    ld a,(hl)           ;hl=firstRow
72
64
    dec (hl)            ;scroll up
73
65
    or a                        ;if firstRow was 0, we need to load a new line of text
74
66
    jr nz,tK_skip
75
 
         ld (hl),7       ;reset firstRow
 
67
         ld (hl),5       ;reset firstRow to 5
76
68
;shift gbuf down 6 pixels
77
 
     ld hl,gbuf+(10*6)*7
78
 
         ld de,gbuf+(10*6)*8    ;last byte of gbuf
 
69
     ld hl,gbuf+((10*6)*8)-1
 
70
         ld de,gbuf+((10*6)*9)-1        ;last byte of gbuf, remember there is one row drawn offscreen
79
71
     ld bc,(6*10)*8             ;each row is 6 pixels tall, there are 8 rows of text
80
72
     lddr
81
73
;clear bottom part of gbuf
82
 
;     ld c,6*10                 ;b=0 from ldir
83
 
;     ld l,e
84
 
;     ld h,d
85
 
;     inc de
86
 
;     ld (hl),a                 ;byte to copy
87
 
;        ldir                           ;erase the space where we'll draw the text     
 
74
     ld c,(6*10)-1              ;b=0 from ldir
 
75
     ld hl,gbuf
 
76
         ld de,gbuf+1
 
77
         ld (hl),a                      ;byte to copy (a should = 0)
 
78
         ldir                           ;erase the space where we'll draw the text     
88
79
     ld hl,letRow
89
 
     ld (hl),0                  ;fill in the text at row 49
90
 
         ld hl,currentLine      ;advance a line
91
 
     ld c,(hl)
 
80
     ld (hl),1                  ;fill in the text at row 1
 
81
     ld hl,fullText
 
82
     ld (hl),0
 
83
         ld hl,currentLine
92
84
     dec (hl)                   ;push pointer back one line
93
 
     ld hl,newLineStorage
94
 
     add hl,bc                  ;newLineStorage + currentLine-1: find position of the text stored below
95
 
     ld c,(hl)
96
 
         ld hl,textBuffer
97
 
         add hl,bc
98
 
     call displayTextDown
99
 
     jr tK_skip
100
 
 
 
85
     ld c,(hl)                  ;if currentline = 0, we need bc to equal $FFFF (-1)
 
86
     dec bc                             ; the byte before newlinestorage was set to 0 at the start of the program
 
87
     jr tK_updateText
 
88
 
 
89
textKeys:
 
90
    ld de,w2_loop
 
91
    push de
 
92
    ld hl,firstRow
 
93
    rra
 
94
    jp nc,tK_down
 
95
    bit 2,a         ;normally up would be bit 3, but we have the rra
 
96
    jr z,tK_up
 
97
    ret
 
98
 
101
99
;##########################
102
100
;#WAIT2ND
103
101
;#Wait for the 2nd key to be pressed.