emailler/test/httpd.s

208 lines
3.8 KiB
ArmAsm
Raw Normal View History

; test the "Kipper Kartridge API"
2013-12-13 21:24:03 +00:00
.ifndef KPR_API_VERSION_NUMBER
.define EQU =
2013-12-13 21:24:03 +00:00
.include "../inc/kipper_constants.i"
.endif
.include "../ip65/copymem.s"
; load A/X macro
.macro ldax arg
.if (.match (.left (1, arg), #)) ; immediate mode
lda #<(.right (.tcount (arg)-1, arg))
ldx #>(.right (.tcount (arg)-1, arg))
.else ; assume absolute or zero page
lda arg
ldx 1+(arg)
.endif
.endmacro
2013-12-13 21:24:03 +00:00
; store A/X macro
.macro stax arg
sta arg
stx 1+(arg)
.endmacro
2013-12-13 21:24:03 +00:00
print_a = $ffd2
.macro cout arg
lda arg
jsr print_a
.endmacro
.zeropage
temp_ptr: .res 2
.bss
kipper_param_buffer: .res $20
block_number: .res $0
.segment "STARTUP"
2013-12-13 21:24:03 +00:00
.macro print arg
ldax arg
ldy #KPR_PRINT_ASCIIZ
jsr KPR_DISPATCH_VECTOR
.endmacro
2013-12-13 21:24:03 +00:00
.macro print_cr
lda #13
jsr print_a
2013-12-13 21:24:03 +00:00
.endmacro
.macro call arg
ldy arg
jsr KPR_DISPATCH_VECTOR
2013-12-13 21:24:03 +00:00
.endmacro
; look for KIPPER signature at location pointed at by AX
look_for_signature:
2013-12-13 21:24:03 +00:00
stax temp_ptr
ldy #5
@check_one_byte:
lda (temp_ptr),y
cmp kipper_signature,y
bne @bad_match
dey
bpl@check_one_byte
2013-12-13 21:24:03 +00:00
clc
rts
@bad_match:
sec
rts
2013-12-13 21:24:03 +00:00
init:
ldax #KPR_CART_SIGNATURE ; where signature should be in cartridge
jsr look_for_signature
2013-12-13 21:24:03 +00:00
bcc @found_kipper_signature
jmp kipper_signature_not_found
@found_kipper_signature:
2013-12-13 21:24:03 +00:00
lda #14
jsr print_a ; switch to lower case
2013-12-13 21:24:03 +00:00
print #initializing
lda #$4c
sta $4000
ldax #print_vars
stax $4001
2013-12-13 21:24:03 +00:00
ldy #KPR_INITIALIZE
jsr KPR_DISPATCH_VECTOR
bcc :+
2013-12-13 21:24:03 +00:00
print #failed
jsr print_errorcode
jmp bad_boot
: print #ok
2013-12-13 21:24:03 +00:00
print_cr
2013-12-13 21:24:03 +00:00
call #KPR_PRINT_IP_CONFIG
print #listening
ldax #httpd_callback
; ldax #$0000
2013-12-13 21:24:03 +00:00
call #KPR_HTTPD_START
jsr print_errorcode
rts
2013-12-13 21:24:03 +00:00
print_vars:
lda #'h'
call #KPR_HTTPD_GET_VAR_VALUE
bcs :+
call #KPR_PRINT_ASCIIZ
print #said
lda #'m'
call #KPR_HTTPD_GET_VAR_VALUE
bcs :+
call #KPR_PRINT_ASCIIZ
print_cr
: rts
2013-12-13 21:24:03 +00:00
bad_boot:
print #press_a_key_to_continue
restart:
2013-12-13 21:24:03 +00:00
jsr get_key
jmp $fce2 ; do a cold start
2013-12-13 21:24:03 +00:00
print_errorcode:
print #error_code
call #KPR_GET_LAST_ERROR
call #KPR_PRINT_HEX
print_cr
rts
; use C64 Kernel ROM function to read a key
; inputs: none
; outputs: A contains ASCII value of key just pressed
2013-12-13 21:24:03 +00:00
get_key:
jsr $ffe4
cmp #0
beq get_key
rts
2013-12-13 21:24:03 +00:00
kipper_signature_not_found:
ldy #0
: lda kipper_signature_not_found_message,y
2013-12-13 21:24:03 +00:00
beq restart
jsr print_a
iny
jmp :-
httpd_callback:
jsr print_vars
ldax #html
ldy #2 ; text/html
2013-12-13 21:24:03 +00:00
clc
rts
.rodata
2013-12-13 21:24:03 +00:00
kipper_signature:
.byte "KIPPER" ; API signature
error_code:
2013-12-13 21:24:03 +00:00
.asciiz "ERROR CODE: $"
press_a_key_to_continue:
.byte "PRESS A KEY TO CONTINUE",13,0
failed:
.byte "FAILED ",0
2013-12-13 21:24:03 +00:00
ok:
.byte "OK ",0
kipper_signature_not_found_message:
.byte "NO KIPPER API FOUND",13,"PRESS ANY KEY TO RESET",0
initializing:
2013-12-13 21:24:03 +00:00
.byte "INITIALIZING ",0
listening:
.byte "LISTENING",0
said:
.byte ":",0
html:
.byte "<h1>hello world</h1>%?mMessage recorded as '%$h:%$m'%.<form>Your Handle:<input name=h type=text length=20 value='%$h'><br>Your Message: <input type=text lengh=60 name='m'><br><input type=submit></form><br>",0
; -- LICENSE FOR test_httpd.s --
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 --