emailler/inc/commonprint.inc

394 lines
7.3 KiB
PHP
Raw Normal View History

2013-12-13 21:24:03 +00:00
.ifndef SCREEN_WIDTH
SCREEN_WIDTH = 40
.endif
2018-02-23 15:17:28 +00:00
.include "zeropage.inc"
2013-12-13 21:24:03 +00:00
.export print_hex
.export print_ip_config
.export dhcp_msg
.export ok_msg
.export failed_msg
.export init_msg
.export print
.export print_ascii_as_native
.export print_integer
.export print_dotted_quad
.export mac_address_msg
.export ip_address_msg
.export netmask_msg
.export gateway_msg
.export dns_server_msg
.export tftp_server_msg
.import ip65_error
.export print_errorcode
.export press_a_key_to_continue
2013-12-13 21:24:03 +00:00
.import ascii_to_native
Removed Ethernet driver I/O base. So far the base address of the Ethernet chip was a general property of all Ethernet drivers. It served two purposes: 1. Allowing to use a single Ethernet driver for a certain Ethernet chip, no matter what machine was connected to the chip. 2. Allowing use an Ethernet card in all Apple II slots. However, we now use customized Ethernet drivers for the individual machines so 1.) isn't relevant anymore. In fact one wants to omit the overhead of a runtime-adjustable base address where it isn't needed. So only the Apple II slots are left. But this should rather be a driver-internal approach then. We should just hand the driver the slot number the user wants to use and have the driver do its thing. Independently from the aspect if the driver parameter is a base address or a slot number the parameter handling was changed too. For asm programs there was so far a specific init function to be called prior to the main init function if it was desired to chnage the parameter default. This was done to keep the main init function backward compatible. But now that the parameter (now the slot number) is only used on the Apple II anyhow it seems reasonable to drop the specific init function again and just provide the parameter to the main init function. All C64-only user code can stay as-is. Only Apple II user code needs to by adjusted. Please note that this change only affects asm programs, C programs always used a single init function with the Apple II slot number as parameter.
2019-05-02 12:44:24 +00:00
.import eth_name
2013-12-13 21:24:03 +00:00
.importzp copy_src
.import cfg_mac
.import cfg_ip
.import cfg_netmask
.import cfg_gateway
.import cfg_dns
.import dhcp_server
2013-12-13 21:24:03 +00:00
.import cfg_tftp_server
pptr = ptr1
2013-12-13 21:24:03 +00:00
2013-12-13 21:24:03 +00:00
.bss
2013-12-13 21:24:03 +00:00
temp_bin: .res 2
temp_bcd: .res 3
temp_ptr: .res 2
2013-12-13 21:24:03 +00:00
.code
.macro print_hex_double arg
lda #>(.right (.tcount (arg)-1, arg))
jsr print_hex
lda #<(.right (.tcount (arg)-1, arg))
jsr print_hex
2013-12-13 21:24:03 +00:00
.endmacro
.macro print_driver_init
Removed Ethernet driver I/O base. So far the base address of the Ethernet chip was a general property of all Ethernet drivers. It served two purposes: 1. Allowing to use a single Ethernet driver for a certain Ethernet chip, no matter what machine was connected to the chip. 2. Allowing use an Ethernet card in all Apple II slots. However, we now use customized Ethernet drivers for the individual machines so 1.) isn't relevant anymore. In fact one wants to omit the overhead of a runtime-adjustable base address where it isn't needed. So only the Apple II slots are left. But this should rather be a driver-internal approach then. We should just hand the driver the slot number the user wants to use and have the driver do its thing. Independently from the aspect if the driver parameter is a base address or a slot number the parameter handling was changed too. For asm programs there was so far a specific init function to be called prior to the main init function if it was desired to chnage the parameter default. This was done to keep the main init function backward compatible. But now that the parameter (now the slot number) is only used on the Apple II anyhow it seems reasonable to drop the specific init function again and just provide the parameter to the main init function. All C64-only user code can stay as-is. Only Apple II user code needs to by adjusted. Please note that this change only affects asm programs, C programs always used a single init function with the Apple II slot number as parameter.
2019-05-02 12:44:24 +00:00
ldax #eth_name
2013-12-13 21:24:03 +00:00
jsr print_ascii_as_native
ldax #init_msg
jsr print_ascii_as_native
.endmacro
.macro print_dhcp_init
ldax #dhcp_msg
jsr print_ascii_as_native
ldax #init_msg
jsr print_ascii_as_native
2013-12-13 21:24:03 +00:00
.endmacro
.macro print_failed
ldax #failed_msg
jsr print_ascii_as_native
2013-12-13 21:24:03 +00:00
jsr print_cr
.endmacro
.macro print_ok
ldax #ok_msg
jsr print_ascii_as_native
2013-12-13 21:24:03 +00:00
jsr print_cr
.endmacro
.code
.import print_a
.import print_cr
Removed Ethernet driver I/O base. So far the base address of the Ethernet chip was a general property of all Ethernet drivers. It served two purposes: 1. Allowing to use a single Ethernet driver for a certain Ethernet chip, no matter what machine was connected to the chip. 2. Allowing use an Ethernet card in all Apple II slots. However, we now use customized Ethernet drivers for the individual machines so 1.) isn't relevant anymore. In fact one wants to omit the overhead of a runtime-adjustable base address where it isn't needed. So only the Apple II slots are left. But this should rather be a driver-internal approach then. We should just hand the driver the slot number the user wants to use and have the driver do its thing. Independently from the aspect if the driver parameter is a base address or a slot number the parameter handling was changed too. For asm programs there was so far a specific init function to be called prior to the main init function if it was desired to chnage the parameter default. This was done to keep the main init function backward compatible. But now that the parameter (now the slot number) is only used on the Apple II anyhow it seems reasonable to drop the specific init function again and just provide the parameter to the main init function. All C64-only user code can stay as-is. Only Apple II user code needs to by adjusted. Please note that this change only affects asm programs, C programs always used a single init function with the Apple II slot number as parameter.
2019-05-02 12:44:24 +00:00
.import eth_name
2013-12-13 21:24:03 +00:00
print_ip_config:
2013-12-13 21:24:03 +00:00
ldax #interface_type
jsr print_ascii_as_native
Removed Ethernet driver I/O base. So far the base address of the Ethernet chip was a general property of all Ethernet drivers. It served two purposes: 1. Allowing to use a single Ethernet driver for a certain Ethernet chip, no matter what machine was connected to the chip. 2. Allowing use an Ethernet card in all Apple II slots. However, we now use customized Ethernet drivers for the individual machines so 1.) isn't relevant anymore. In fact one wants to omit the overhead of a runtime-adjustable base address where it isn't needed. So only the Apple II slots are left. But this should rather be a driver-internal approach then. We should just hand the driver the slot number the user wants to use and have the driver do its thing. Independently from the aspect if the driver parameter is a base address or a slot number the parameter handling was changed too. For asm programs there was so far a specific init function to be called prior to the main init function if it was desired to chnage the parameter default. This was done to keep the main init function backward compatible. But now that the parameter (now the slot number) is only used on the Apple II anyhow it seems reasonable to drop the specific init function again and just provide the parameter to the main init function. All C64-only user code can stay as-is. Only Apple II user code needs to by adjusted. Please note that this change only affects asm programs, C programs always used a single init function with the Apple II slot number as parameter.
2019-05-02 12:44:24 +00:00
ldax #eth_name
2013-12-13 21:24:03 +00:00
jsr print_ascii_as_native
jsr print_cr
2013-12-13 21:24:03 +00:00
ldax #mac_address_msg
jsr print_ascii_as_native
ldax #cfg_mac
2013-12-13 21:24:03 +00:00
jsr print_mac
jsr print_cr
ldax #ip_address_msg
jsr print_ascii_as_native
ldax #cfg_ip
jsr print_dotted_quad
2013-12-13 21:24:03 +00:00
jsr print_cr
ldax #netmask_msg
jsr print_ascii_as_native
ldax #cfg_netmask
jsr print_dotted_quad
2013-12-13 21:24:03 +00:00
jsr print_cr
ldax #gateway_msg
jsr print_ascii_as_native
ldax #cfg_gateway
jsr print_dotted_quad
2013-12-13 21:24:03 +00:00
jsr print_cr
ldax #dns_server_msg
jsr print_ascii_as_native
ldax #cfg_dns
jsr print_dotted_quad
2013-12-13 21:24:03 +00:00
jsr print_cr
ldax #tftp_server_msg
jsr print_ascii_as_native
ldax #cfg_tftp_server
jsr print_dotted_quad
jsr print_cr
ldax #dhcp_server_msg
jsr print_ascii_as_native
ldax #dhcp_server
jsr print_dotted_quad
2013-12-13 21:24:03 +00:00
jsr print_cr
rts
2013-12-13 21:24:03 +00:00
print:
sta pptr
stx pptr + 1
2013-12-13 21:24:03 +00:00
@print_loop:
ldy #0
lda (pptr),y
beq @done_print
jsr print_a
inc pptr
bne @print_loop
2013-12-13 21:24:03 +00:00
inc pptr+1
bne @print_loop ; if we ever get to $ffff, we've probably gone far enough ;-)
2013-12-13 21:24:03 +00:00
@done_print:
rts
print_ascii_as_native:
sta pptr
stx pptr + 1
2013-12-13 21:24:03 +00:00
@print_loop:
ldy #0
lda (pptr),y
beq @done_print
2013-12-13 21:24:03 +00:00
jsr ascii_to_native
jsr print_a
inc pptr
bne @print_loop
2013-12-13 21:24:03 +00:00
inc pptr+1
bne @print_loop ; if we ever get to $ffff, we've probably gone far enough ;-)
2013-12-13 21:24:03 +00:00
@done_print:
rts
; print the 4 bytes pointed at by AX as dotted decimals
2013-12-13 21:24:03 +00:00
print_dotted_quad:
sta pptr
stx pptr + 1
2013-12-13 21:24:03 +00:00
lda #0
@print_one_byte:
pha
tay
2013-12-13 21:24:03 +00:00
lda (pptr),y
ldx #0
jsr print_integer
2013-12-13 21:24:03 +00:00
pla
cmp #3
beq @done
clc
adc #1
pha
lda #'.'
jsr print_a
pla
bne @print_one_byte
@done:
rts
; print 6 bytes printed at by AX as a MAC address
2013-12-13 21:24:03 +00:00
print_mac:
stax pptr
2013-12-13 21:24:03 +00:00
ldy #0
@one_mac_digit:
tya ; just to set the Z flag
2013-12-13 21:24:03 +00:00
pha
beq @dont_print_colon
lda #':'
jsr print_a
@dont_print_colon:
pla
2013-12-13 21:24:03 +00:00
tay
lda (pptr),y
jsr print_hex
iny
cpy #06
bne @one_mac_digit
rts
print_integer: ; print 16 bit number in AX as a decimal number
2013-12-13 21:24:03 +00:00
; hex to bcd routine taken from Andrew Jacob's code at http://www.6502.org/source/integers/hex2dec-more.htm
stax temp_bin
sed ; Switch to decimal mode
lda #0 ; Ensure the result is clear
2013-12-13 21:24:03 +00:00
sta temp_bcd
sta temp_bcd+1
sta temp_bcd+2
ldx #16 ; The number of source bits
: asl temp_bin+0 ; Shift out one bit
2013-12-13 21:24:03 +00:00
rol temp_bin+1
lda temp_bcd+0 ; And add into result
2013-12-13 21:24:03 +00:00
adc temp_bcd+0
sta temp_bcd+0
lda temp_bcd+1 ; propagating any carry
2013-12-13 21:24:03 +00:00
adc temp_bcd+1
sta temp_bcd+1
lda temp_bcd+2 ; ... thru whole result
2013-12-13 21:24:03 +00:00
adc temp_bcd+2
sta temp_bcd+2
dex ; And repeat for next bit
bne :-
stx temp_bin+1 ; x is now zero - reuse temp_bin as a count of non-zero digits
cld ; back to binary
2013-12-13 21:24:03 +00:00
ldx #2
stx temp_bin+1 ; reuse temp_bin+1 as loop counter
2013-12-13 21:24:03 +00:00
@print_one_byte:
ldx temp_bin+1
lda temp_bcd,x
pha
lsr
lsr
lsr
lsr
jsr @print_one_digit
pla
and #$0f
jsr @print_one_digit
dec temp_bin+1
bpl @print_one_byte
rts
@print_one_digit:
cmp #0
beq @this_digit_is_zero
inc temp_bin ; increment count of non-zero digits
@ok_to_print:
2013-12-13 21:24:03 +00:00
clc
adc #'0'
jsr print_a
rts
@this_digit_is_zero:
ldx temp_bin ; how many non-zero digits have we printed?
2013-12-13 21:24:03 +00:00
bne @ok_to_print
ldx temp_bin+1 ; how many digits are left to print?
2013-12-13 21:24:03 +00:00
bne @this_is_not_last_digit
inc temp_bin ; to get to this point, this must be the high nibble of the last byte.
; by making 'count of non-zero digits' to be >0, we force printing of the last digit
@this_is_not_last_digit:
rts
2013-12-13 21:24:03 +00:00
print_hex:
pha
pha
2013-12-13 21:24:03 +00:00
lsr
lsr
lsr
lsr
tax
lda hexdigits,x
jsr print_a
pla
and #$0F
tax
lda hexdigits,x
jsr print_a
pla
rts
print_errorcode:
ldax #error_code
jsr print_ascii_as_native
lda ip65_error
jsr print_hex
jmp print_cr
2013-12-13 21:24:03 +00:00
.rodata
2013-12-13 21:24:03 +00:00
hexdigits:
.byte "0123456789ABCDEF"
2013-12-13 21:24:03 +00:00
.if SCREEN_WIDTH >= 30
2013-12-13 21:24:03 +00:00
interface_type:
.byte "Interface : ",0
2013-12-13 21:24:03 +00:00
mac_address_msg:
.byte "MAC Address : ",0
2013-12-13 21:24:03 +00:00
ip_address_msg:
.byte "IP Address : ",0
2013-12-13 21:24:03 +00:00
netmask_msg:
.byte "Netmask : ",0
2013-12-13 21:24:03 +00:00
gateway_msg:
.byte "Gateway : ",0
2013-12-13 21:24:03 +00:00
dns_server_msg:
.byte "DNS Server : ",0
2013-12-13 21:24:03 +00:00
dhcp_server_msg:
.byte "DHCP Server : ",0
2013-12-13 21:24:03 +00:00
tftp_server_msg:
.byte "TFTP Server : ",0
.else ; for small width screens e.g. VIC 20
2013-12-13 21:24:03 +00:00
interface_type:
.byte "Interface", 10,0
2013-12-13 21:24:03 +00:00
mac_address_msg:
.byte "MAC Address",10,0
2013-12-13 21:24:03 +00:00
ip_address_msg:
.byte "IP Address", 10,0
2013-12-13 21:24:03 +00:00
netmask_msg:
.byte "Netmask", 10,0
2013-12-13 21:24:03 +00:00
gateway_msg:
.byte "Gateway", 10,0
2013-12-13 21:24:03 +00:00
dns_server_msg:
.byte "DNS Server", 10,0
2013-12-13 21:24:03 +00:00
dhcp_server_msg:
.byte "DHCP Server",10,0
2013-12-13 21:24:03 +00:00
tftp_server_msg:
.byte "TFTP Server",10,0
2013-12-13 21:24:03 +00:00
.endif
dhcp_msg:
.byte "DHCP",0
init_msg:
.byte 10,"Initializing ",0
2013-12-13 21:24:03 +00:00
failed_msg:
.byte "failed",0
2013-12-13 21:24:03 +00:00
ok_msg:
.byte "OK",0
2013-12-13 21:24:03 +00:00
dns_lookup_failed_msg:
.byte "DNS LOOKUP FAILED",0
2013-12-13 21:24:03 +00:00
error_code:
2013-12-13 21:24:03 +00:00
.asciiz "error code: "
press_a_key_to_continue:
.byte "Press a key to continue",10,0
; -- LICENSE FOR commonprint.inc --
2013-12-13 21:24:03 +00:00
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
2013-12-13 21:24:03 +00:00
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --