📄 guesslet.asm
字号:
;;======================================================================
;; 下面是猜字游戏的程序 ;;
;; programer:zl. ;;
;; data:2004.4 ;;
;; info: ;;
;;======================================================================
dui_cuo:
db ' 对: 错: '
db ' '
;;---------------------------------------------------------
guessword:
Loff_Lcd_Icon icon_uppage
Loff_Lcd_Icon iconup
Loff_Lcd_Icon icon_downpage
Loff_Lcd_Icon icondown
jsr CALL_LUpdateScreen
lda #9 ;#8
sta ItemNo ;;zl
lda #<guessword-1 ;;zl.帮助功能 |->
sta HelpRtPrc
lda #>guessword-1
sta HelpRtPrc+1
jsr drr_rt_to_drr
lda #>guess_help_new
sta helptextph
lda #<guess_help_new
sta helptextpl ;;->|
;;========================================================================
stz <newflag ;;zl.(equ cdata+20 in newench.asm)
stz not_correctword ;;zl.
stz correctword ;;zl.猜对的单词数
stz word_counter ;;zl.一组单词多少的变量
stz guess_answer_flag ;;zl.提示键按下次数标志
jsr get_first_word_address ;; 单词地址初始化
;;======================================================================
guess_loop:
stz guessrightnum ;;zl.一个单词中猜对的字母数
jsr get_first_word_address_0;;地址转化
lda <temp ;;
bne guess_loop_11
jmp have_finish ;;
guess_loop_11:
stz textpagenum_study ;;zl.设置成在第0页
jsr clear_word_showword ;;zl.清空wordlocation/showwordlocation变量区
jsr unpress_english ;;zl.解压出英文,放在wordlocation中
jsr copy_word2showword ;;zl.
jsr jishu_wordlength ;;
jsr jishu_trytimes ;;
jsr cls_screen ;;
jsr display_duicuo
lda correctword ;;\
sta temp1 ;;|zl.input of display_duicuocount
lda #disp_location_1 ;;|
sta temp2 ;;/
jsr display_duicuocount
lda not_correctword
sta temp1
lda #disp_location_2
sta temp2
jsr display_duicuocount
jsr guess_question_display
guess_display_end:
jmp guess_backmain
;;-------------------------------------------------------------------
guess_next_question:
jsr guess1group_overjudge ;;zl.判断是否一组结束
lda <temp
beq ?11
?00: ;;结束来这里
jsr cls_screen
jmp fill_have_finish
?11:
jsr current_addr_addc_4
jmp guess_loop
;;===================================================================
;;-------------------------------------------------------------------
;;======== 猜字键控 zl.===========================================
;;-------------------------------------------------------------------
guess_Key_table:
db esckey,enterkey,LanKey,NullKey ;;NullKey equ 080H in data.def zl.
guess_Key_Prcgram:
dw guessesckey-1
dw guessenterkey-1
dw guessanswerKey-1 ;;zl.用做提示键
;;-------------------------------------------------------------------
guessesckey:
jmp tfillesckey
;;---------------------------------------------------------------
guessenterkey:
stz <newflag
lda guess_tishi_flag
beq ?end
stz guess_tishi_flag
jmp guess_next_question
?end:
jmp guess_backmain
;;-------- answer key -------------------------------------------
guessanswerKey:
lda guess_answer_flag
bne ?answer
lda #1
sta guess_answer_flag
inc guessrightnum ;;zl.是否是最后一个字母了
lda guessrightnum
cmp letterwordlength
beq ?answer
jsr guess_display_one_letter ;;不是一个字母到这里
jmp guess_backmain
?answer:
stz guess_answer_flag
lda #1
sta guess_tishi_flag
guessanswerKey_1:
jsr display_rightansweris
jsr display_guess_answer
inc not_correctword
lda #3
jsr music_8times_off
jmp guess_backmain
;;==============================================================
guess_backmain:
lmainu
;;--------------------------------------------------------------
;;=========== 猜字游戏按键事件 =============================
;;--------------------------------------------------------------
guesskeyin:
ldy #0ffh
guesskeyin_loop: ;;
iny
lda guess_key_table,y ;;zl.判断是那个功能键
bmi guesskeyinend ;;zl.判断是否到了键表结束位置(判断N标志位,如果为1就跳转)
cmp <keyNO ;;zl.是不是被触发的按键
bne guesskeyin_loop ;;zl.不是的话继续找
tya ;;zl.是的话,跳到相应的键功能
asl ;;zl.db-->dw转化 乘2
tay ;;
lda guess_Key_Prcgram+1,y ;;\
pha ;;|
lda guess_Key_Prcgram,y ;;|zl.跳到表guess_Key_Prcgram的相应位置
pha ;;|
rts ;;/
;;-------------------------------------------------------------------
guesskeyinend: ;;功能键寻找结束
guess_small_letter: ;;字母键寻找开始
ldy #0ffh ;;
guess_small_letter_loop: ;;
iny ;;
lda small_letter_key_table,y;;zl.与大写字母表是同样的,即是在查所有的字母键
bmi guess_small_letter_end ;;zl.查表结束跳转
cmp <keyNo ;;
bne guess_small_letter_loop ;;
lda #IconShift&0ffh ;;zl.取得“Iconshift”的低8位,("&"是与符号)
and IconShift>>8 ;;zl.把IconShift逻辑右移8位,它是5位的16进制数/20位2进制数
bne guess_to_da_xie ;;
lda small_letter_table,y ;;zl.添空的是小写字母
bra guessinputchar00
guess_to_da_xie:
lda large_letter_table,y ;;zl.添空的是大写字母
bra guessinputchar00
guess_small_letter_end: ;;没有字母/功能键时输入时跳回主程序
jmp guess_backmain
;;-------------------------------------------------------------------
guessinputchar00: ;;zl.显示填空的字母
sta <temp ;;zl.字母的值存到"temp"里
;putsio <temp
;;====================================================================
guess_input_loop:
jsr guess_right
lda temp1
beq ?11
inc correctword ;;zl.猜对的单词数加1
?00: ;;zl.每猜对一个单词(词组)来这里
jsr cls_screen
jsr display_answerright
lda #2
jsr music_8times_off
jsr delay1s
jsr delay1s
jsr delay1s
jmp guess_next_question
?11: ;;zl.没猜对来这里
jsr dec_jishu_trytimes
lda temp1
beq ?12
bra ?22
?12:
jmp guess_backmain
?22: ;;zl.没猜对但是猜够次数了来这里
inc not_correctword
jsr cls_screen
jsr display_rightansweris
jsr display_guess_answer
lda #1
jsr music_8times_off
jsr delay1s
jsr delay1s
jmp guess_next_question
;;------------------------------------------------------------------
;;******************************************************************
;;================ subrountine =====================================
;;******************************************************************
;;------------------------------------------------------------------
;;function:按提示键后,提示一个字母
;;input:showwordlocation
;;output:showwordlocation,textbuffor
;;------------------------------------------------------------------
guess_display_one_letter:
ldy #0
?loop:
lda showwordlocation,y
beq ?end
cmp #20h
bne ?display
iny
bra ?loop
?display:
lda showwordlocation,y
pha
lda #20h
sta showwordlocation,y
tya
clc
adc #textbufforrow2
tay
pla
sta textbuffor,y
jsr CALL_LUpdateScreen
?end:
rts
;;------------------------------------------------------------------
;;function:可以猜字的次数减1,并判断是否为0
;;input:keyvalue_L,keyvalue_H
;;output:temp1
;;------------------------------------------------------------------
dec_jishu_trytimes:
lda keyvalue_L
beq ?00
dec keyvalue_L
beq ?11
bra ?01
?00:
lda keyvalue_H
beq ?zero
dec keyvalue_H
lda #0ffh
sta keyvalue_L
?01:
stz temp1
rts
?11:
lda keyvalue_H
beq ?zero
bra ?01
?zero:
lda #1
sta temp1
rts
;;------------------------------------------------------------------
;;function:计算可以猜字的次数
;;input:letterwordlength
;;output:keyvalue_L,keyvalue_H
;;------------------------------------------------------------------
jishu_trytimes:
stz keyvalue_L
stz keyvalue_H
lda letterwordlength
sta keyvalue_L ;;zl.letterwordlength*4
asl keyvalue_L
rol keyvalue_H
asl keyvalue_L
rol keyvalue_H
rts
;;------------------------------------------------------------------
;;function:判断按键字母是否正确
;;input:<temp(kevalue),letterwordlength
;;output:temp1
;;------------------------------------------------------------------
guess_right:
ldy #0
?loop:
lda showwordlocation,y
beq ?end
cmp <temp
beq ?display
?loop_1:
iny
bra ?loop
?display:
lda #20h
sta showwordlocation,y
tya
clc
adc #textbufforrow2
tay
lda <temp
sta textbuffor,y
jsr CALL_LUpdateScreen
inc guessrightnum
lda guessrightnum
cmp letterwordlength
beq ?right
?end:
stz temp1
rts
?right:
stz guessrightnum
lda #1
sta temp1
rts
;;------------------------------------------------------------------
;;function:把wordlocation中的内容拷贝到showwordlocation中
;;input:wordlocation
;;output:showwordlocation
;;------------------------------------------------------------------
copy_word2showword:
ldy #0ffh
?copyloop:
iny
lda wordlocation,y
sta showwordlocation,y
bne ?copyloop
rts
;;------------------------------------------------------------------
;;function:显示right_answer_is
;;input:
;;output:
;;------------------------------------------------------------------
display_rightansweris:
ldy #0ffh
?00:
iny
lda right_answer_is,y
sta textbuffor,y
cpy #40
bne ?00
jsr CALL_LUpdateScreen
rts
;;------------------------------------------------------------------
;;function:显示right_answer
;;input:
;;output:
;;------------------------------------------------------------------
display_answerright:
ldy #0ffh
?00:
iny
lda answer_right,y
sta textbuffor,y
cpy #100 ;;zl.+c
bne ?00
jsr CALL_LUpdateScreen
rts
;;------------------------------------------------------------------
;;function:显示答对/错字符
;;input:
;;output:
;;------------------------------------------------------------------
display_duicuo:
ldy #0ffh
?00:
iny
lda dui_cuo,y
sta textbuffor,y
cpy #40
bne ?00
rts
;;------------------------------------------------------------------
;;function:显示答对/错的题目数
;;input:temp1,temp2 (correctword,not_correctword,displaylocation)
;;output:
;;------------------------------------------------------------------
display_duicuocount:
ldy temp2
lda temp1
lsr a
lsr a
lsr a
lsr a
clc
adc #30h
sta textbuffor,y
inc temp2
ldy temp2
lda temp1
and #0fh
clc
adc #30h
sta textbuffor,y
jsr CALL_LUpdateScreen
rts
;;------------------------------------------------------------------
;;function:显示空格(问题)(空格数和wordlength相等)
;;input:wordlocation
;;output:'_'and' '
;;------------------------------------------------------------------
guess_question_display:
ldy #0ffh
?loop:
iny
lda showwordlocation,y
beq ?end
cmp #0dh ;;zl.回车
beq ?22
cmp #41h ;;A
bcc ?00
cmp #5ah ;;Z
bcc ?11
beq ?11
cmp #61h ;;a
bcc ?00
cmp #7ah ;;z
bcc ?11
beq ?11
bra ?00
?00:
lda #20h
bra ?display
?11:
lda #'_'
bra ?display
?22:
lda showwordlocation,y
bra ?display
bra ?end
?display:
pha
tya
clc
adc #textbufforrow2
tax
pla
sta textbuffor,x
bra ?loop
?end:
jsr CALL_LUpdateScreen
rts
;;------------------------------------------------------------------
;;function:显示正确答案
;;input:wordlocation
;;output:
;;------------------------------------------------------------------
display_guess_answer:
ldy #0
?00:
lda wordlocation,y
beq ?11
pha
tya
clc
adc #textbufforrow2
tax
iny
pla
sta textbuffor,x
bra ?00
?11:
jsr CALL_LUpdateScreen
rts
;;------------------------------------------------------------------
;;function:清空wordlocation and showwordlocation
;;input:
;;output:
;;------------------------------------------------------------------
clear_word_showword:
ldy #0
clear_wordlocation_loop:
lda #0
sta wordlocation,y
sta showwordlocation,y
tya
cmp #40
beq clear_wordlocation_end
iny
bra clear_wordlocation_loop
clear_wordlocation_end:
rts
;;------------------------------------------------------------------
;;function:判断是否1组结束
;;input:#max_word_num
;;output:temp
;;------------------------------------------------------------------
guess1group_overjudge:
inc word_counter
lda word_counter
;;cmp #max_word
cmp #max_word_num ;;zl.
bne ?00
?11:
lda #1
sta <temp
rts
?00:
stz <temp
rts
;;------------------------------------------------------------------
;;function:清显示缓冲变量区第一页
;;input:无
;;output:textbuffor(连续的变量区)
;;------------------------------------------------------------------
cls_screen:
ldy #0
?00:
lda #20h
sta textbuffor,y
iny
cpy #100
bne ?00
rts
;;====================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -