diff --git a/src/hxload.asm b/src/hxload.asm index 5958b49..11590cb 100644 --- a/src/hxload.asm +++ b/src/hxload.asm @@ -23,6 +23,8 @@ XDEF _hxload_vdp XDEF _startaddress XDEF _endaddress + XDEF _datarecords + XDEF _defaultAddressUsed LOAD_HLU_DEFAULT .EQU 04h ; 0x040000 default load address @@ -30,11 +32,21 @@ _hxload_uart1: PUSH DE PUSH HL PUSH BC - + + LD DE,0 + LD (_datarecords), DE ; clear number of data records + LD A, 1 + LD (_defaultAddressUsed), A + + LD A, LOAD_HLU_DEFAULT + LD (hexload_address + 2),A ; store HLU XOR A,A LD (hexload_error),A ; clear error counter - LD A, 1 - LD (firstwrite),A ; firstwrite = true + LD (hexload_address + 1),A ; clear address[15:0] - this will be loaded from record type 0 + LD (hexload_address),A + LD HL, hexload_address + LD HL,(HL) ; load assembled address from memory into HL as a pointer + LD (_startaddress),HL ; store first address hxline: CALL _uart1_getch @@ -65,18 +77,32 @@ hex_address: LD (hexload_address),A LD HL, hexload_address LD HL,(HL) ; load assembled address from memory into HL as a pointer - ld A,(firstwrite) ; is this the first address we write to? - CP A,1 - JR NZ, $F ; if not, skip storing the first address - XOR A,A ; firstwrite = false - LD (firstwrite),A - LD (_startaddress),HL ; store first address + + PUSH BC + PUSH HL + PUSH DE + LD BC, HL ; temp pointer in BC + LD HL, (_datarecords) + LD DE, 0 ; compare HL,0 + OR A ; compare HL,0 + SBC HL,DE ; compare HL,0 + ADD HL,DE ; compare HL,0 + JR NZ, $F + LD HL, BC ; restore temp pointer + LD (_startaddress), HL ; no data record received; record start address + XOR A,A + LD (_defaultAddressUsed), A; using this address record, not using default $$: + POP DE + POP HL + POP BC + CALL getbyte ; load checksum LD A,E OR A JR NZ, hexckerr ; checksum error on this line JR hxline + hexdata: CALL getbyte LD (HL),A @@ -88,6 +114,11 @@ hexdata: OR A ; sum of all data incl checksum should be zero JR NZ, hexckerr ; checksum error on this line LD (_endaddress), HL ; store end address + PUSH HL + LD HL, (_datarecords) + INC HL ; increase number of datarecords + LD (_datarecords), HL + POP HL JR hxline hexckerr: LD A,(hexload_error) @@ -246,4 +277,6 @@ hexload_address DS 3 ; 24bit address hexload_error DS 1 ; error counter firstwrite DS 1 ; boolean _startaddress DS 3 ; first address written to -_endaddress DS 3 ; last address written to \ No newline at end of file +_endaddress DS 3 ; last address written to +_datarecords DS 3 ; number of data records read +_defaultAddressUsed DS 1 ; boolean \ No newline at end of file diff --git a/src/main.c b/src/main.c index 532fe0a..e65042f 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,8 @@ extern VOID uart1_handler(void); // external variables extern volatile UINT24 startaddress; extern volatile UINT24 endaddress; +extern volatile UINT24 datarecords; +extern volatile UINT8 defaultAddressUsed; // single VDP function needed UINT8 vdp_cursorGetXpos(void); @@ -92,7 +94,13 @@ void handle_hexload_uart1(UINT24 baudrate) // Only feedback during transfer - we have no time to output to VDP or even UART1 between received bytes printf("Receiving Intel HEX records - UART1:%d 8N1\r\n",baudrate); c = hxload_uart1(); - if(c == 0) printf("OK\r\n"); + if(c == 0) { + printf("%d datarecords\r\n",datarecords); + printf("Start address 0x%06X",startaddress); + if(defaultAddressUsed) printf(" (default)\r\n"); + else printf("\r\n"); + printf("OK\r\n"); + } else printf("%d error(s)\r\n",c); // close UART1, so no more interrupts will trigger before removal of handler