NOTICE TEXTE n° 1 (27.71 Ko)
;;
;; ça compile sous winape32 ORG &8000:RUN &8000
;;
;; TAB=16
;;
;; v0.1 19xx
;; v0.2 2014 +CAT<3K +MIRROR +UP/DOWN +FIXES
;;
charset &e9,"{"
charset &e8,"}"
charset &e0,"@"
BUFFER_CAT equ &0040
macro mNextLine
ld a,h
add a,8
ld h,a
jr nc,@no_over
ld a,l
add a,80
ld l,a
ld a,h
adc a,&c0
ld h,a
@no_over
mend
macro mNextRow
ld a,l
add a,80
ld l,a
adc a,h
sub l
ld h,a
mend
macro mNextLineDEMinus4
ld a,e
add a,&fc
ld e,a
ld a,d
adc a,&07
ld d,a
jr nc,@no_over
ld a,e
add a,80
ld e,a
ld a,d
adc a,&c0
ld d,a
@no_over
mend
DBG equ 0
POSX_ZOOM equ 16
POSX_FONTS equ 4
POSY_FONTS equ 12
POSY_STATUS equ 24
POSY_SAMPLE equ 10
KEY_CLR equ &10
KEY_BACKSPACE equ &7f
KEY_SPACE equ &20
KEY_COPY equ &e0
KEY_ESCAPE EQU &fc
KEY_UP EQU &f0
KEY_DOWN EQU &f1
KEY_LEFT equ &f2
KEY_RIGHT equ &f3
KEY_SHIFT_UP equ &f4
KEY_SHIFT_DOWN equ &f5
KEY_SHIFT_LEFT equ &f6
KEY_SHIFT_RIGHT equ &f7
KEY_CTRL_UP equ &f8
KEY_CTRL_DOWN equ &f9
KEY_CTRL_LEFT equ &fa
KEY_CTRL_RIGHT equ &fb
;; &00
KEY_CTRLA equ &01
KEY_CTRLB equ &02
KEY_CTRLC equ &03
KEY_CTRLD equ &04
KEY_CTRLE equ &05
KEY_CTRLF equ &06
KEY_CTRLG equ &07
KEY_CTRLH equ &08
KEY_CTRLI equ &09
KEY_CTRLJ equ &0a
KEY_CTRLK equ &0b
KEY_CTRLL equ &0c
KEY_CTRLM equ &0d
KEY_CTRLN equ &0e
KEY_CTRLO equ &0f
KEY_CTRLP equ &10
KEY_CTRLQ equ &11
KEY_CTRLR equ &12
KEY_CTRLS equ &13
KEY_CTRLT equ &14
KEY_CTRLU equ &15
KEY_CTRLV equ &16
KEY_CTRLW equ &17
KEY_CTRLX equ &18
KEY_CTRLY equ &19
KEY_CTRLZ equ &1a
;; &1b
;; &1c
;; &1d
;; &1e
;; &1f
KL_LOW_PCHL equ &000b
KL_LOW_PCBC equ &000e
KL_SIDE_PCHL equ &0013
KL_PCDE equ &0016
KL_FAR_PCHL equ &001b
KL_PCHL equ &001e
KL_FAR_ICALL equ &0023
KL_U_ROM_ENABLE equ &b900
KL_U_ROM_DISABLE equ &b903
KL_L_ROM_ENABLE equ &b906
KL_L_ROM_DISABLE equ &b909
KL_ROM_RESTORE equ &b90c
KL_ROM_SELECT equ &b90f
KL_CURR_SELECTION equ &b912
KL_PROBE_ROM equ &b915
KL_ROM_DESELECT equ &b918
KL_LDIR equ &b91b
KL_LDDR equ &b91e
KL_POLL_SYNCHRONOUS equ &b921
;;#b924???
;;#b927???
KL_SCAN_NEEDED equ &b92a
KM_INITIALISE equ &bb00
KM_RESET equ &bb03
KM_WAIT_CHAR equ &bb06
KM_READ_CHAR equ &bb09
KM_CHAR_RETURN equ &bb0c
KM_SET_EXPAND equ &bb0f
KM_GET_EXPAND equ &bb12
KM_EXP_BUFFER equ &bb15
KM_WAIT_KEY equ &bb18
KM_READ_KEY equ &bb1b
KM_TEST_KEY equ &bb1e
KM_GET_STATE equ &bb21
KM_GET_JOYSTICK equ &bb24
KM_SET_TRANSLATE equ &bb27
KM_GET_TRANSLATE equ &bb2a
KM_SET_SHIFT equ &bb2d
KM_GET_SHIFT equ &bb30
KM_SET_CONTROL equ &bb33
KM_GET_CONTROL equ &bb36
KM_SET_REPEAT equ &bb39
KM_GET_REPEAT equ &bb3c
KM_SET_DELAY equ &bb3f
KM_GET_DELAY equ &bb42
KM_ARM_BREAKS equ &bb45
KM_DISARM_BREAK equ &bb48
KM_BREAK_EVENT equ &bb4b
TXT_INITIALISE equ &bb4e
TXT_RESET equ &bb51
TXT_VDU_ENABLE equ &bb54
TXT_VDU_DISABLE equ &bb57
TXT_OUTPUT equ &bb5a
TXT_WRITE_CHAR equ &bb5d
TXT_READ_CHAR equ &bb60
TXT_SET_GRAPHIC equ &bb63
TXT_WIN_ENABLE equ &bb66
TXT_GET_WINDOW equ &bb69
TXT_CLEAR_WINDOW equ &bb6c
TXT_SET_COLUMN equ &bb6f
TXT_SET_ROW equ &bb72
TXT_SET_CURSOR equ &bb75
TXT_GET_CURSOR equ &bb78
TXT_CUR_ENABLE equ &bb7b
TXT_CUR_DIABLE equ &bb7e
TXT_CUR_ON equ &bb81
TXT_CUR_OFF equ &bb84
TXT_VALIDATE equ &bb87
TXT_PLACE_CURSOR equ &bb8a
TXT_REMOVE_CURSOR equ &bb8d
TXT_SET_PEN equ &bb90
TXT_GET_PEN equ &bb93
TXT_SET_PAPER equ &bb96
TXT_GET_PAPER equ &bb99
TXT_INVERSE equ &bb9c
TXT_SET_BACK equ &bb9f
TXT_GET_BACK equ &bba2
TXT_GET_MATRIX equ &bba5
TXT_SET_MATRIX equ &bba8
TXT_SET_M_TABLE equ &bbab
TXT_GET_M_TABLE equ &bbae
TXT_GET_CONTROLS equ &bbb1
TXT_STR_SELECT equ &bbb4
TXT_SWAP_STREAMS equ &bbb7
GRA_INITIALISE equ &bbba
GRA_RESET equ &bbbd
GRA_MOVE_ABSOLUTE equ &bbc0
GRA_MOVE_RELATIVE equ &bbc3
GRA_ASK_CURSOR equ &bbc6
GRA_SET_ORIGIN equ &bbc9
GRA_GET_ORIGIN equ &bbcc
GRA_WIN_WIDTH equ &bbcf
GRA_WIN_HEIGHT equ &bbd2
GRA_GET_W_WIDTH equ &bbd5
GRA_GET_W_HEIGHT equ &bbd8
GRA_CLEAR_WINDOW equ &bbdb
GRA_SET_PEN equ &bbde
GRA_GET_PEN equ &bbe1
GRA_SET_PAPER equ &bbe4
GRA_GET_PAPER equ &bbe7
GRA_PLOT_ABSOLUTE equ &bbea
GRA_PLOT_RELATIVE equ &bbed
GRA_TEST_ABSOLUTE equ &bbf0
GRA_TEST_RELATIVE equ &bbf3
GRA_LINE_ABSOLUTE equ &bbf6
GRA_LINE_RELATIVE equ &bbf9
GRA_WR_CHAR equ &bbfc
SCR_INITIALISE equ &bbff
SCR_RESET equ &bc02
SCR_SET_OFFSET equ &bc05
SCR_SET_BASE equ &bc08
SCR_GET_LOCATION equ &bc0b
SCR_SET_MODE equ &bc0e
SCR_GET_MODE equ &bc11
SCR_CLEAR equ &bc14
SCR_CHAR_LIMITS equ &bc17
SCR_CHAR_POSITION equ &bc1a
SCR_DOT_POSITION equ &bc1d
SCR_NEXT_BYTE equ &bc20
SCR_PREV_BYTE equ &bc23
SCR_NEXT_LINE equ &bc26
SCR_PREV_LINE equ &bc29
SCR_INK_ENCODE equ &bc2c
SCR_INK_DECODE equ &bc2f
SCR_SET_INK equ &bc32
SCR_GET_INK equ &bc35
SCR_SET_BORDER equ &bc38
SCR_GET_BORDER equ &bc3b
SCR_SET_FLASHING equ &bc3e
SCR_GET_FLASHING equ &bc41
SCR_FILL_BOX equ &bc44
SCR_FLOOD_BOX equ &bc47
SCR_CHAR_INVERT equ &bc4a
SCR_HW_ROLL equ &bc4d
SCR_SW_ROLL equ &bc50
SCR_UNPACK equ &bc53
SCR_REPACK equ &bc56
SCR_ACCESS equ &bc59
SCR_PIXELS equ &bc5c
SCR_HORIZONTAL equ &bc5f
SCR_VERTICAL equ &bc62
CAS_INITIALISE equ &bc65
CAS_SET_SPEED equ &bc68
CAS_NOISY equ &bc6b
CAS_START_MOTOR equ &bc6e
CAS_STOP_MOTOR equ &bc71
CAS_RESTORE_MOTOR equ &bc74
CAS_IN_OPEN equ &bc77
CAS_IN_CLOSE equ &bc7a
CAS_IN_ABANDON equ &bc7d
CAS_IN_CHAR equ &bc80
CAS_IN_DIRECT equ &bc83
CAS_RETURN equ &bc86
CAS_TEST_EOF equ &bc89
CAS_OUT_OPEN equ &bc8c
CAS_OUT_CLOSE equ &bc8f
CAS_OUT_ABANDON equ &bc92
CAS_OUT_CHAR equ &bc95
CAS_OUT_DIRECT equ &bc98
CAS_CATALOG equ &bc9b
CAS_WRITE equ &bc9e
CAS_READ equ &bca1
CAS_CHECK equ &bca4
SOUND_RESET equ &bca7
SOUND_QUEUE equ &bcaa
SOUND_CHECK equ &bcad
SOUND_ARM_EVENT equ &bcb0
SOUND_RELEASE equ &bcb3
SOUND_HOLD equ &bcb6
SOUND_CONTINUE equ &bcb9
SOUND_AMPL_ENVELOPE equ &bcbc
SOUND_TONE_ENVELOPE equ &bcbf
SOUND_A_ADDRESS equ &bcc2
SOUND_T_ADDRESS equ &bcc5
KL_CHOKE_OFF equ &bcc8
KL_ROM_WALK equ &bccb
KL_INIT_BACK equ &bcce
KL_LOG_EXT equ &bcd1
KL_FIND_COMMAND equ &bcd4
KL_NEW_FRAME_FLY equ &bcd7
KL_ADD_FRAME_FLY equ &bcda
KL_DEL_FRAME_FLY equ &bcdd
KL_NEW_FAST_TICKER equ &bce0
KL_ADD_FAST_TICKER equ &bce3
KL_DEL_FAST_TICKER equ &bce6
KL_ADD_TICKER equ &bce9
KL_DEL_TICKER equ &bcec
KL_INIT_EVENT equ &bcef
KL_EVENT equ &bcf2
KL_SYNC_RESET equ &bcf5
KL_DEL_SYNCHRONOUS equ &bcf8
KL_NEXT_SYNCH equ &bcfb
KL_DO_SYNCH equ &bcfe
KL_DONE_SYNCH equ &bd01
KL_EVENT_DISABLE equ &bd04
KL_EVENT_ENABLE equ &bd07
KL_DISARM_EVENT equ &bd0a
KL_TIME_PLEASE equ &bd0d
KL_TIME_SET equ &bd10
MC_BOOT_PROGRAM equ &bd13
MC_START_PROGRAM equ &bd16
MC_WAIT_FLYBACK equ &bd19
MC_SET_MODE equ &bd1c
MC_SCREEN_OFFSET equ &bd1f
MC_CLEAR_INKS equ &bd22
MC_SET_INKS equ &bd25
MC_RESET_PRINTER equ &bd28
MC_PRINT_CHAR equ &bd2b
MC_PRINTER_BUSY equ &bd2e
MC_SEND_PRINTER equ &bd31
MC_SOUND_REGISTER equ &bd34
JUMP_RESTORE equ &bd37
KM_SET_LOCKS equ &bd3a
;KM_GET_LOCKS equ &bd3d???
TXT_ASK_STATE equ &bd40
GRA_DEFAULT equ &bd43
GRA_SET_BACK equ &bd46
GRA_SET_FIRST equ &bd49
GRA_SET_LINE_MASK equ &bd4c
GRA_FROM_USER equ &bd4f
GRA_FILL equ &bd52
SCR_SET_POSITION equ &bd55
MC_PRINT_TRANSLATION equ &bd58
KL_BANK_SWITCH equ &bd5b
IND_TXT_DRAW_CURSOR equ &bdcd
IND_TXT_UNDRAW_CURSOR equ &bdd0
IND_TXT_WRITE_CHAR equ &bdd3
IND_TXT_UNWRITE equ &bdd6
IND_TXT_OUT_ACTION equ &bdd9
IND_GRA_PLOT equ &bddc
IND_GRA_TEST equ &bddf
IND_GRA_LINE equ &bde2
IND_SCR_READ equ &bde5
IND_SCR_WRITE equ &bde8
IND_SCR_MODE_CLEAR equ &bdeb
IND_KM_TEST_BREAK equ &bdee
IND_MC_WAIT_PRINTER equ &bdf1
IND_KM_SCAN_KEYS equ &bdf4
;;
FILE_TYPE_BAS equ 0
FILE_TYPE_BIN equ 2
;;
ERR_14 equ 14
ERR_15 equ 15
ERR_BAD_COMMAND equ &10
ERR_ALREADY_EXISTS equ 17 ;; WHAT ?
ERR_NOT_FOUND equ &12
ERR_DIR_FULL equ 19
ERR_DISC_FULL equ 20
ERR_DISC_CHANGED equ 21
ERR_READ_ONLY equ 22
ERR_EOF equ 26
ERR_READ_FAIL equ &41 ;; b0 Address mark missing
ERR_WRITE_PROTECTED equ &42 ;; b1 Not writable - disc is write protected
ERR_FAIL equ &44 ;; b2 No data - can't find the sector
ERR_DISC_MISSING equ &48
ERR_OVERRUN equ &50
ERR_DATA_ERROR equ &60 ;; b5 Data error - CRC error
;; b6 = FDC ERROR
;; b7 = 1 Amsdos à rapporté l'erreur
;;putc equ PrintSys
IT_FILENAME equ &80
;
;
;
;;include "..\_cpc.asm"
;
;
;
main
ld hl,(&be7d)
ld a,(hl)
ld (current_drive),a
ld hl,boot
ld c,&ff
jp MC_START_PROGRAM
boot
ld l,c
ld h,b
call &bccb
ld a,(current_drive)
ld hl,(&be7d)
ld (hl),a
IFNOT DBG
ld a,1
ld (&be78),a ;; AMSDOS disable Retry, Cancel, Ignore
ENDIF
;;
;;
;;
ld a,1
call SCR_SET_MODE
IFNOT DBG
call TXT_VDU_DISABLE ;; cache erreur disk
ENDIF
ld hl,palette
call SetPalette
call CopyFontFromROM
ld a,"A"
ld (current_char),a
ld hl,0
ld (pointer_xy),hl
ld a,h
add a,POSX_ZOOM
ld h,a
call GetScrnPosition
ld (pointer_scrn),hl
main_redraw
;;call CLS
call ReDrawInterface
ld hl,status_welcome
call SetStatus
main_loop
call ShowInfos
call HiliteChar
ld a,(current_char)
call GetMatrix
call ZoomChar
ld e,0
;
;; boucle principale
;
wait_key
call MC_WAIT_FLYBACK
;; faire clignoter le curseur en attendant une touche
ld hl,(pointer_scrn)
ld a,e
and &0f
call Z,Blinking_Zoom
inc e
call KM_READ_CHAR
jr nc,wait_key
;; chercher la touche dans la table
ld hl,table_key
ld d,a
ld bc,3
find_key
ld a,(hl)
or a
jr z,char_key ;; pas trouvé alors sélectionner car
cp d
jr z,good_key
add hl,bc
jr find_key
char_key
ld a,d
ld (current_char),a
jr main_loop
good_key
ld a,e
inc hl
ld e,(hl)
inc hl
ld d,(hl)
;; effacer curseur
and &10
ld hl,(pointer_scrn)
call z,Blinking_Zoom
ld a,(current_char)
call GetMatrix
ex de,hl ;; DE=CHAR BITMAP
call KL_PCHL
jr main_loop
CursorLeft
ld hl,(pointer_xy)
ld a,h
or a
ret z
dec h
CursorUpdate
ld (pointer_xy),hl
ld a,h
add a,POSX_ZOOM
ld h,a
call GetScrnPosition
ld (pointer_scrn),hl
ret
CursorRight
ld hl,(pointer_xy)
ld a,h
cp 7
ret z
inc h
jr CursorUpdate
CursorUP
ld hl,(pointer_xy)
ld a,l
or a
ret z
dec l
jr CursorUpdate
CursorDown
ld hl,(pointer_xy)
ld a,l
cp 7
ret z
inc l
jr CursorUpdate
PrevChar
ld hl,current_char
dec (hl)
ret
NextChar
ld hl,current_char
inc (hl)
ret
CharUP
ld a,(current_char)
sub 32
ld (current_char),a
ret
CharDown
ld a,(current_char)
add a,32
ld (current_char),a
ret
InverseBit ;; COPY / SPACE
ld hl,(pointer_xy)
ld a,e
add a,l
ld e,a
ex de,hl
ld a,&01
inc d
IB_loop
rrca
dec d
jr nz,IB_loop
xor (hl)
ld (hl),a
jp RefreshChar
;;
;; inverser caractère
;;
InverseChar
ld b,8
IC_loop
ld a,(de)
cpl
ld (de),a
inc e
djnz IC_LOOP
jp RefreshChar
InvMirror
ld b,8
IM_loop
ld a,(de)
repeat 8
rla
rr c
rend
ld a,c
ld (de),a
inc e
djnz IM_loop
jp RefreshChar
InvUpDown
ld a,e
add a,7
ld l,a
ld h,d
repeat 4
ld c,(hl)
ld a,(de)
ld (hl),a
ld a,c
ld (de),a
inc e
dec l
rend
jp RefreshChar
;
;; effacer caractère
;
ClearChar
xor a
repeat 8
ld (de),a
inc e
rend
jp RefreshChar
;
;; Copier caractère
;
ClipCopy
ex de,hl
ld de,clipboard
repeat 8
ldi
rend
ret
;
;; Coller caractère
;
ClipPaste
ld hl,clipboard
repeat 8
ldi
rend
jr RefreshChar
;
;; Couper caractère
;
ClipCut
call ClipCopy ;; O:HL=CHAR+8
xor a
repeat 8
dec hl
ld (hl),a
rend
jr RefreshChar
;
;; Scrolling caractère
;
ScrollUp
ld l,e
ld h,d
ld a,(hl)
inc l
repeat 7
ldi
rend
ld (de),a
jr RefreshChar
ScrollDown
ld a,e
add a,7
ld e,a
ld a,(de)
ld l,e
ld h,d
dec l
repeat 7
ldd
rend
ld (de),a
jr RefreshChar
ScrollLeft
ex de,hl
repeat 8
rlc (hl)
inc l
rend
jr RefreshChar
ScrollRight
ex de,hl
repeat 8
rrc (hl)
inc l
rend
jr RefreshChar
;
;; In : ---
;; Out: ???
;
RefreshChar
ld a,(current_char)
ld l,a
and &1f ;;%000XXXXX
ld h,a
xor l ;;%XXX00000
rlca
rlca
rlca
ld l,a
ld de,POSX_FONTS*256+POSY_FONTS
add hl,de
call GetScrnPosition
ld a,(current_char)
call PrintMatrix
ld hl,text_sample
ld a,(current_char)
ld b,a
RS_loop
ld a,(hl)
or a
ret z
cp b
jp z,ShowSample
inc hl
jr RS_loop
;; M:A/HL
HiliteChar
ld a,(hilited)
or a
jr z,no_hilited
ld a,(current_char)
ld l,a
ld a,(hilited_char)
cp l
ret z
call RestoreHilite
no_hilited
push de
ld a,(current_char)
ld (hilited_char),a
ld l,a
and &1f
add a,POSX_FONTS-1
ld h,a
ld a,l
rlca
rlca
rlca
and &07
add a,POSY_FONTS-1
ld l,a
ld (hilited),a ;; <>0
call GetScrnPosition
call SaveHilite
pop de
ret
SaveHilite
inc l
ld a,h
add a,6*8 ;; sauter 6 lignes
ld h,a
ld (hilited_scrn),hl
ld bc,&c7d0 ;; 48 octets pile poil
ld de,sprite_hilite
ld ixl,12
SH_loop
push hl
ex de,hl
repeat 4
ld a,(de)
ld (bc),a
and (hl)
inc hl
or (hl)
inc hl
ld (de),a
inc de
inc bc
rend
ex de,hl
pop hl
mNextLine
dec ixl
jr nz,SH_loop
ret
RestoreHilite
ld hl,(hilited_scrn)
ld bc,&08ff
ld de,&c7d0
ex de,hl
call RH_UD
RH_loop
ldi
inc l
inc l
inc de
inc de
ldi
mNextLineDEMinus4
djnz RH_loop
RH_UD
repeat 2
ldi
ldi
ldi
ldi
mNextLineDEMinus4
rend
ret
;
;
;
ZoomChar ;; HL=MATRIX
ex de,hl
ld hl,POSX_ZOOM*256
call GetScrnPosition
ld ixl,8
sc_nextline
ld b,8
ld a,(de)
ld c,a
push de
sc_nextbit
rl c
ld de,sprite_on
jr c,sc_loop
ld de,sprite_off
sc_loop
ld a,(de)
ld (hl),a
inc e
inc l
ld a,(de)
ld (hl),a
inc e
dec l
ld a,h
add a,8
ld h,a
jr nc,sc_loop
ld de,&c002
add hl,de
djnz sc_nextbit
pop de
inc de
ld a,l
add a,80-16
ld l,a
adc a,h
sub l
ld h,a
dec ixl
jr nz,sc_nextline
ret
;; HL=SCRN
Blinking_Zoom
push bc
ld bc,&FF08
ld a,(hl)
xor b
ld (hl),a
inc l
ld a,(hl)
xor b
ld (hl),a
dec l
ld a,h
add a,c
ld h,a
repeat 6
ld a,(hl)
xor &88
ld (hl),a
inc l
ld a,(hl)
xor &11
ld (hl),a
dec l
ld a,h
add a,c
ld h,a
rend
ld a,(hl)
xor b
ld (hl),a
inc l
ld a,(hl)
xor b
ld (hl),a
dec l
ld a,h
add &c0
ld h,a
pop bc
ret
ShowInfos
ld hl,&0202
call GetScrnPosition
ld a,(current_char)
ld b,a
ld de,text_hex
call puts
ld a,b
call hex_byte
ld hl,&0204
call GetScrnPosition
ld de,text_dec
call puts
ld a,b
call dec_byte
ld hl,&0206
call GetScrnPosition
ld de,text_asc
call puts
ld a,b
call PrintSys
ret
InitBlinking
xor a
ld (bool_blinking),a
ret
HideBlinking
;;
;; &01 OFF>ON
;; &02 &03 &04 &05 06 07 08 09 10
;; &11 ON>OFF
;;
ld a,(bool_blinking)
dec a
and &10
call z,SetBlinking
xor a
ld (bool_blinking),a
ret
;;
;; I:HL=SCRN
;; O:???
;; M:???
;;
Blinking ld a,(bool_blinking)
inc a
ld (bool_blinking),a
dec a
and &0f
ret nz
SetBlinking
push bc
ld bc,&FF08
Blinking_loop
ld a,(hl)
xor b
ld (hl),a
inc l
ld a,(hl)
xor b
ld (hl),a
dec l
ld a,h
add a,c
ld h,a
jr nc,Blinking_loop
sub &40
ld h,a
pop bc
ret
ChangeSampleText
ld hl,text_sample
ld de,status_sample
ld b,32
xor a
call InputText
call ClearStatus
jp ShowSample
;
;; FN : InputText
;; Inp: A=FLAGS HL=(sz)buffer DE=(sz)message B=max len (<40)
;; Out: A=LEN HL=SCRN DE=??? BC=???
;; BUG:le curseur déconne parfois
;
InputText
ld (input_flags),a
ex de,hl
call SetStatus
ld a,(input_flags)
and IT_FILENAME
call nz,ShowDrive
;; HL=SCRN DE=BUFF
xor a
ld c,a
ld (need_redraw),a
IT_printbuff
ld a,(de)
or a
jr z,IT_EOL
call PrintSys
inc de
inc c
jr IT_printbuff
IT_EOL
;; C=LEN B=MAXLEN DE=à la fin du texte HL=SCRN
IT_waitkey
push de
call InitBlinking
IT_waitkey_loop
call MC_WAIT_FLYBACK
call Blinking
call KM_READ_CHAR
jr nc,IT_waitkey_loop
ld d,a
call HideBlinking
ld a,d
pop de
cp a,KEY_ESCAPE
jr z,InputTextCancel
cp a,13
jr z,InputTextValid
cp a,9
jr z,InputTextCompletion
cp a,KEY_CTRLD
jr z,InputTextChangeDrive
cp a,KEY_CLR
jr z,InputTextClear
cp a,32
jr c,IT_waitkey
cp a,127
jr z,IT_backspace
cp a,128
jr nc,IT_waitkey
;; 32-126
ld (de),a
ld a,c
cp b
jr nc,IT_waitkey ;; plus de place dans le buffer
ld a,(de)
inc de
inc c
call PrintSys
jr IT_waitkey
IT_Refresh
ld a,(need_redraw)
or a
ret z
push bc
push de
push hl
call CLS
Call ReDrawInterface
pop hl
pop de
pop bc
ret
ReDrawInterface
xor a
ld (hilited),a
call show_fonts
jp ShowSample
InputTextValid
call IT_Refresh
xor a
ld (de),a
ld a,c
scf
ret
InputTextCancel
call IT_Refresh
xor a
ld (de),a
ret
InputTextClear
ld a,c
or a
jr z,IT_waitkey
InputTextClear_loop
dec de
dec hl
dec l
call ClearCharAtScrn
dec c
jr nz,InputTextClear_loop
jp IT_waitkey
IT_backspace
ld a,c
or a
jp z,IT_waitkey
dec de
dec hl
dec l
dec c
call ClearCharAtScrn
jp IT_waitkey
InputTextChangeDrive
call ChangeDrive
jp IT_waitkey
InputTextCompletion
ld a,(input_flags)
and IT_FILENAME
jp z,IT_waitkey
;; HL=SCRN
;; DE=EOL
;; C=LEN
;; B=MAXLEN
push bc
push de
push hl
ld de,BUFFER_CAT
call CAS_CATALOG
jr c,ITC_fail ;; NC=OK ???
call CLS
ld de,BUFFER_CAT
ld hl,0 ;; X,Y
ITC_loop_catalog
ld a,(de)
or a
jr z,ITC_stop
inc de
ld c,e
ld b,d
ld a,e
add a,12
ld e,a
adc a,d
sub e
ld d,a
ld a,(de)
or a ;; >256 kos
jr nz,ITC_too_bigH
dec de
ld a,(de)
cp 4
jr nc,ITC_too_bigL ;; >4 kos
ld e,c
ld d,b
ld bc,&087f
push hl
call GetScrnPosition
ITC_loop_base
ld a,(de)
and c
call PrintSys
inc de
djnz ITC_loop_base
ld a,"."
call PrintSys
ld b,3
ITC_loop_ext
ld a,(de)
and c
call PrintSys
inc de
djnz ITC_loop_ext
pop hl
inc l
ld a,l
cp 24
jr c,ITC_no_eos
ld a,h
add a,13 ;; TODO
ld h,a
ld l,0
ITC_no_eos
ITC_too_bigL
inc de
ITC_too_bigH
inc de
jr ITC_loop_catalog
ITC_stop
cpl
ld (need_redraw),a
ITC_fail
pop hl
pop de
pop bc
jp IT_waitkey
ChangeDrive
ld a,&01
db &fe ;; TRICK CP &xx/XOR A
ShowDrive
xor a
ShowDrive2
push hl
ld hl,(&be7d)
xor (hl)
ld (hl),a
add "A"
push af
ld hl,38*256+24
call GetScrnPosition
pop af
call PrintSys
ld a,":"
call PrintSys
pop hl
ret
;
;
;
ShowSample
ld hl,0*256+POSY_SAMPLE
call GetScrnPosition
ld de,text_sample
ld b,40
ss_loop
ld a,(de)
or a
jr z,SS_ceol
call PrintMatrix
inc de
jr ss_loop
SS_ceol
ld a," "
call PrintMatrix
djnz SS_ceol
ret
;;
;; INP:---
;; OUT:---
;;
show_fonts ;; ---
ld hl,POSX_FONTS*256+POSY_FONTS
call GetScrnPosition
ld de,&001f
ld bc,80-64
SF_loop_line
SF_loop
ld a,d
call PrintMatrix
inc d
ld a,d
and e
jr nz,SF_loop
add hl,bc ;; next line
ld a,d
or a
jr nz,SF_loop_line
ret
GetMatrix ;; A=CHAR -> HL=MATRIX
ld h,0
add a,a
rl h
add a,a
rl h
add a,a
rl h
add a,buffer_font and &ff
ld l,a
ld a,h
adc a,buffer_font/256
ld h,a
ret
PrintSys ;; A=CHAR HL=SCRN
push bc
push de
ex de,hl
ld l,a
ld h,7
add hl,hl
add hl,hl
add hl,hl
call KL_L_ROM_ENABLE
ld b,&f0
PS_loop
ld c,(hl)
ld a,c
and b
ld (de),a
inc e
xor c
rlca
rlca
rlca
rlca
ld (de),a
dec e
inc l
ld a,d
add a,8
ld d,a
jr nc,PS_loop
ex de,hl
sub &40
ld h,a
inc l
inc hl
call KL_L_ROM_DISABLE
pop de
pop bc
ret
;
;; In : A=CHAR HL=SCRN
;; Out: ---
;
PrintMatrix ;; HL=SCRN A=CHAR
push bc
push de
ex de,hl
call GetMatrix
PM_loop
ld a,(hl)
and &f0
ld (de),a
inc e
ld a,(hl)
add a,a
add a,a
add a,a
add a,a
ld (de),a
dec e
inc l
ld a,d
add a,8
ld d,a
jr nc,PM_loop
ex de,hl
sub &40
ld h,a
inc l
inc hl
pop de
pop bc
ret
;
;; In :H=X L=Y
;; Out:HL=SCRN AF=???
;
GetScrnPosition ;; H=X L=Y (MODE 1)
push de
ld a,l ;; 0-31
add a,a
add a,a
add a,a
ld l,a
ld a,h
add a,a ;; MODE 1
ld h,0
add hl,hl
ld e,l
ld d,h
add hl,hl
add hl,hl
add hl,de
add a,l
ld l,a
ld a,h
adc a,&c0
ld h,a
pop de
ret
ResetFont
call CopyFontFromROM
pop hl
jp main_redraw
CopyFontFromROM
call KL_L_ROM_ENABLE
ld hl,&3800
ld de,buffer_font
ld bc,256*8
ldir
jp KL_L_ROM_DISABLE
;; DISK
SaveFont
ld hl,filename
ld de,status_filename
push hl
ld b,14
ld a,IT_FILENAME
call InputText
pop hl
or a
jp z,ClearStatus
ld b,a
call CAS_OUT_OPEN
jr nc,SaveFont_fail
;; clean header
ld a,l
add a,69
ld e,a
adc a,h
sub e
ld d,a
ld bc,24
ld hl,status_welcome
ldir
ld l,e
ld h,d
dec hl
ld c,&23
ldir
;;
ld hl,buffer_font
ld de,256*8
ld bc,0
ld a,FILE_TYPE_BIN
call CAS_OUT_DIRECT
jr nc,SaveFont_fail
call CAS_OUT_CLOSE
jr nc,SaveFont_fail
ld hl,status_save_ok
jp SetStatus
SaveFont_fail
push af ;; A=ERROR
ld hl,status_error
call SetStatus
pop af
ld e,a
rrca
rrca
rrca
rrca
and &0f
cp &0a
sbc &69
daa
call PrintSys
ld a,e
and &0f
cp &0a
sbc &69
daa
call PrintSys
jp CAS_OUT_ABANDON
;
;;
;
OpenFont
ld hl,filename
ld de,status_filename
push hl
ld b,14
ld a,IT_FILENAME
call InputText
pop hl
or a
jp z,ClearStatus
ld b,a
call CAS_IN_OPEN
jr nc,OpenFont_fail
;; BC=LEN
;; &0300=32-127
;; &0800=0-255
ld a,c
or a
ret nz
ld hl,buffer_font
ld a,b
cp &08
jr z,OF_fullfont
inc h
cp &03
jp z,OF_fullfont
ld hl,status_fnt_size
call SetStatus
jp CAS_IN_ABANDON
OF_fullfont
call CAS_IN_DIRECT
jr nc,OpenFont_fail
call CAS_IN_CLOSE
jr nc,OpenFont_fail
pop hl ;; NO MAIN LOOP
jp main_redraw
OpenFont_fail
push af ;; A=ERROR
ld hl,status_error
call SetStatus
pop af
ld e,a
rrca
rrca
rrca
rrca
and &0f
cp &0a
sbc &69
daa
call PrintSys
ld a,e
and &0f
cp &0a
sbc &69
daa
call PrintSys
jp CAS_IN_ABANDON
Help
call FullCLS
ld hl,&c000
ld de,text_help
Help_loopy
ld c,0 ;; CHAR counter
Help_loop
ld a,(de)
or a
jr z,Help_end
inc de
cp &0a
jr z,Help_newline
cp &09
jr z,Help_tab
call PrintSys
inc c
jr Help_loop
Help_tab
ld a,c
add a,8
ld c,a
ld a,l
add a,16
ld l,a
adc a,h
sub l
ld h,a
jr Help_loop
Help_newline
ld a,40
sub c
add a,a
add a,l
ld l,a
adc a,h
sub l
ld h,a
jr Help_loopy
Help_end
call InitBlinking
Help_waitkey
call MC_WAIT_FLYBACK
call Blinking
call KM_READ_CHAR
jr nc,Help_waitkey
call FullCLS
pop hl
jp main_redraw
FullCLS
ld b,25
jr CLS2
CLS
ld b,24
CLS2
ld hl,&c000
CLS_loop
call ClearLine
mNextRow
djnz CLS_loop
xor a
ret
SetPalette
ex de,hl
ld iyl,e
ld iyh,d
ld a,(de)
ld c,a
ld b,a
call SCR_SET_BORDER
ld ixl,0
SP_loop
inc iy
ld a,(iy)
inc a
ret z
dec a
ld c,a
ld b,a
ld a,ixl
call SCR_SET_INK
inc ixl
jr SP_loop
ClearStatus
ld hl,24
call GetScrnPosition
jr ClearLine
;
;; In : HL=message
;; Out: A=??? HL=SCRN
;;
;
SetStatus
push bc
push de
ex de,hl
call ClearStatus
jr SS_EOL
SetStatus_loop
call PrintSys
inc de
SS_EOL
ld a,(de)
or a
jr nz,SetStatus_loop
pop de
pop bc
ret
;
;; In : HL=SCRN (ALIGN 2)
;; Out: AF=???
;
ClearLine
push bc
push de
ld de,&0008
ld c,40
CL_loop
ld b,c
CL_clear1
ld (hl),d
inc l
ld (hl),d
inc hl
djnz CL_clear1
ld a,h
add a,e
ld h,a
ld b,c
CL_clear2
dec hl
ld (hl),d
dec l
ld (hl),d
djnz CL_clear2
ld a,h
add a,e
ld h,a
jr nc,CL_loop
add a,&c0
ld h,a
pop de
pop bc
ret
;;
;; HL=SCRN (align 2)
;;
ClearCharAtScrn
push bc
ld bc,&0008
ld a,h
repeat 4
ld (hl),b
inc l
ld (hl),b
add a,c
ld h,a
ld (hl),b
dec l
ld (hl),b
add a,c
ld h,a
rend
sub &40
ld h,a
pop bc
ret
;
;; DE=text
;
puts
ld a,(de)
or a
ret z
call PrintSys
inc de
jr puts
;
;; A=BYTE
;
hex_byte
push de
ld e,a
rrca
rrca
rrca
rrca
; and &0f
; add "0"
; cp &3a
; jr c,@
; add &07
; @ = 11/10 us
and &0f
cp &0a
sbc &69
daa ;; 7us
call PrintSys
ld a,e
and &0f
cp &0a
sbc &69
daa
pop de
jp PrintSys
;; A=BYTE
dec_byte
push de
ld de,&6430
sub d
jr c,dec_byte2
inc e
sub d
jr c,dec_byte2
inc e
sub d
dec_byte2
ld d,a
ld a,e
call PrintSys
ld a,d
ld de,&0a39
add a,d
jr c,dec_byte3
repeat 8
dec e
add a,d
jr c,dec_byte3
rend
dec e
add a,d
dec_byte3
ld d,a
ld a,e
call PrintSys
ld a,d
add "0"
pop de
jp PrintSys
;
; char/string
;
;; FN : strlen(char *string)
;; In : HL=String+0
;; Out: A=LEN
;
strlen
push bc
push hl
xor a
ld c,a
ld b,a
cpir
ld a,c
cpl
pop hl
pop bc
ret
;; A=CHAR
UpperCase
cp "a"
ret c
cp "z"+1
ret nc
sub &20
ret
;
;
;
table_key
db KEY_LEFT
dw CursorLeft
db KEY_DOWN
dw CursorDown
db KEY_UP
dw CursorUP
db KEY_RIGHT
dw CursorRight
db KEY_SHIFT_LEFT
dw ScrollLeft
db KEY_SHIFT_DOWN
dw ScrollDown
db KEY_SHIFT_UP
dw ScrollUp
db KEY_SHIFT_RIGHT
dw ScrollRight
db KEY_ESCAPE
dw Help
db KEY_SPACE
dw InverseBit
db KEY_COPY
dw InverseBit
db KEY_CTRLT
dw ChangeSampleText
db KEY_CLR
dw ClearChar
db KEY_CTRLI
dw InverseChar
db KEY_CTRLM
dw InvMirror
db KEY_CTRLU
dw InvUpDown
db KEY_CTRLC
dw ClipCopy
db KEY_CTRLV
dw ClipPaste
db KEY_CTRLX
dw ClipCut
db KEY_CTRLR
dw ResetFont
db KEY_CTRL_LEFT
dw PrevChar
db KEY_CTRL_RIGHT
dw NextChar
db KEY_CTRL_UP
dw CharUP
db KEY_CTRL_DOWN
dw CharDown
db KEY_CTRLS
dw SaveFont
db KEY_CTRLO
dw OpenFont
db KEY_CTRLD
dw ChangeDrive
db 0
;
;; TEMP
;
current_drive db 0
input_flags db 0
need_redraw db 0
;
;;
;
bool_blinking db 0
hilited db 0
hilited_char db 0
hilited_scrn dw 0
current_char db 0
palette db 0,0,26,13,6,-1
clipboard ds 8,0
pointer_xy dw 0
pointer_scrn dw 0
filename ds 14+1,0 ;; A:FILENAME.FNT
text_sample db "Amstrad CPC 6128 128k is Ready",0
ds 64,0
status_sample db "Text : ",0
status_welcome db "FontEdit v0.2 by CiPiCi - ESC=Help",0
status_error db "Disc error : &",0
status_save_ok db "Save ok !",0
status_fnt_size db "Wrong size (&300 32-127 or &800 0-255)",0
status_filename db "File or TAB/CTRL+D : ",0
status_drive db "Drive : ",0
status_buffer ds 41,0
text_hex db "hex : &",0
text_dec db "dec : ",0
text_asc db "asc : ",0
text_help db "FontEdit (Free Open Source Software)",10
db 10
db "COPY/SPACE : Pixel ON/OFF",10
db &f0,&f1,&f2,&f3," : Cursor",10
db "CTRL+",&f0,&f1,&f2,&f3," : Choose char (or type char)",10
db "SHIFT+",&f0,&f1,&f2,&f3," : Scroll char",10
db 10
db "CTRL+I/TAB : Inverse",10
db "CTRL+M/RET : Mirror CTRL+U : Inv Vert",10
db "CLR : Clear char",10
db "CTRL+C/V/X : Copy Paste Cut",10
db "CTRL+R : Reset font",10
db "CTRL+T : Edit sample text",10
db 10
;; DISK
db "CTRL+O : Open font",9,"a/b:file.net",10
db "CTRL+S : Save font",9,"or file.net",10
db "CTRL+D : Current drive",10
db 10
db "Input :",10
db 10
db "CLR : Clear line",10
db "DEL : Delete char",10
db "ESC : Abandon",10
db "TAB : Catalog",10
db 9,9,9,"Press any key"
db 0
;;
;; ALIGN 16
;;
align 16
;; &ff = 3
;; &0f = 2
;; &f0 = 1
;; &00 = 0
sprite_off db &00,&00
db &07,&0e ;; %1111
db &07,&0e
db &07,&0e
db &07,&0e
db &07,&0e
db &07,&0e
db &00,&00
sprite_on db &00,&00
db &70,&e0
db &70,&e0
db &70,&e0
db &70,&e0
db &70,&e0
db &70,&e0
db &00,&00
sprite_hilite db %11001100,%00110011,0,&ff,0,&ff,%00110011,%11001100
db %11001100,%00110011,0,&ff,0,&ff,%00110011,%11001100
repeat 8
db %11001100,%00110011,&ff,0,&ff,0,%00110011,%11001100
rend
db %11001100,%00110011,0,&ff,0,&ff,%00110011,%11001100
db %11001100,%00110011,0,&ff,0,&ff,%00110011,%11001100
align 8
buffer_font