]> git.sur5r.net Git - cc65/blob - libsrc/plus4/ksetnam.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / plus4 / ksetnam.s
1 ;
2 ; Ullrich von Bassewitz, 22.11.2002
3 ;
4 ; SETNAM replacement function
5 ;
6
7         .export         SETNAM
8
9         .include        "plus4.inc"
10
11 ; This function is special in that the name must reside in low memory,
12 ; otherwise it is not accessible by the ROM code.
13
14 .segment        "LOWCODE"               ; Must go into low memory
15
16 .proc   SETNAM
17
18 ; Store the length of the name into the zero page
19
20         sta     FNAM_LEN
21
22 ; Check if we have to copy the name to low memory
23
24         cmp     #$00                    ; Length zero?
25         beq     @L3                     ; Yes: Copying not needed
26         cpy     #$00                    ; Is the name in low memory?
27         bpl     @L3                     ; Yes: Copying not needed
28
29 ; Store the length and the pointer to the name
30
31         stx     TMPPTR
32         sty     TMPPTR+1                ; Store pointer to name in TMPPTR
33
34 ; Copy the given name into FNBUF.
35
36         ldy     #$00
37 @L2:    lda     (TMPPTR),y
38         sta     FNBUF,y
39         iny
40         cpy     FNAM_LEN
41         bne     @L2
42
43 ; Load the new parameters for the low memory buffer
44
45         ldx     #<FNBUF
46         ldy     #>FNBUF
47
48 ; Instead of banking in the ROM, store the values directly into the zeropage
49
50 @L3:    stx     FNAM
51         sty     FNAM+1
52
53 ; Return to caller
54
55         rts
56
57 .endproc
58
59